home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 345.lha / snap_v1.4 / snap.doc < prev    next >
Text File  |  1990-02-13  |  22KB  |  603 lines

  1.                      Snap 1.4
  2.                      ========
  3.                (c) Mikael Karlsson 1989
  4.       Keymap inverting courtesy of Jim Mackraz
  5.  
  6.  
  7. Is it Public Domain?
  8.  
  9.   Snap is NOT Public Domain. Snap is 'Freely distributable
  10.   copyrighted software with a shareware option'.
  11.  
  12.   "Permission is hereby granted to copy Snap provided that
  13.    the copyright notice and this document is left intact.
  14.    Copies may not be made for profit."
  15.  
  16.   I don't know if the above should hold in court but what
  17.   I mean is: Copy Snap if you want to but don't make a
  18.   business of it. It is of course free to include it on
  19.   public domain disks or putting it on a BBS.
  20.   If you find Snap useful, please feel free to send a
  21.   donation ($10 is a nice round number) or a nice program (PD).
  22.   Or you can buy me a beer or two when we meet.
  23.   If you wish to include Snap with a commercial product,
  24.   please contact me first. I just want to make sure that
  25.   my ego can stand for it. Of course it would also be nice
  26.   with a registred copy of the product.
  27.   (How about including it with a '030 card? ;-)
  28.  
  29.   Also read this message that Jim Mackraz sent to me regarding
  30.   some code used in Snap:
  31.  
  32.   "You may use ikm.c in your product Snap.
  33.    You may not distribute the source to ikm.c for profit,
  34.    and any distribution of ikm.c must retain the original
  35.    copyright message.
  36.  
  37.    You should also be warned that IKM() has not been
  38.    substantially verified in either design or implementation,
  39.    and that it will be made obsolete in version V1.4 by a
  40.    new OS function call.
  41.  
  42.    There is no explicit or implied guarantee that ikm.c contains
  43.    only supported algorithms.  It may have problems in a future
  44.    release of the system.
  45.  
  46.       jimm
  47.  
  48.    Jim Mackraz
  49.    Aug 18, 1989"
  50.  
  51.  
  52. What is it?
  53.  
  54.   Snap is the perfect tool for the lazy typer. Isn't it
  55.   irritating when you look at something on the screen
  56.   and think: "That is what I'm going to type."?
  57.   What if you could just point at it and get the computer to
  58.   type it for you? That's where Snap comes to the rescue.
  59.   Another thing that irritates me is that I'm sitting in
  60.   front of THE computer and still I must have pen and
  61.   paper available to scribble down something from the screen
  62.   that I know I will need later. Snap provides a solution
  63.   to that problem also. Just frame it and Snap creates a
  64.   window with a copy of the screen contents. Perfect for
  65.   snapping text from later on. This is another idea borrowed
  66.   from the computer scientists at Xerox Palo Alto Research
  67.   Center (you know, the ones who invented the mouse, windows,
  68.   icons and stuff like that).
  69.  
  70.  
  71. Why use Snap instead?
  72.  
  73.    a. Snap finds out the character coordinates automatically.
  74.    b. Snap uses the RastPort's current font, not just Topaz 8.
  75.    c. Snap was written by me.
  76.    d. Snap supports all fixed width fonts with width and height<16.
  77.    e. Snap supports accented characters (128-255).
  78.    f. Snap supports keymaps, thanks to Jim Mackraz.
  79.    g. Snap does both column and text oriented snapping.
  80.    h. Snap snaps graphics.
  81.    i. Snap uses the clipboard, making it compatible with TxED (and NotePad).
  82.    j. Snap understands inverted characters.
  83.    k. Snap understands bold characters.
  84.    l. Snap understands underlined characters
  85.    m. Snap does word oriented snapping.
  86.    n. Snap has ants.
  87.    o. Snap has a key combination to do insert.
  88.    p. Snap supports Xerox style snapping with immediate insert.
  89.    q. Snap prepends and appends characters.
  90.    r. Snap saves graphics.
  91.    s. Snap caches the character offsets between windows.
  92.    t. Snap joins long lines.
  93.    u. Snap supports ARexx to read and set prepend and append strings.
  94.    v. Snap handles an extra pixel line between character rows.
  95.  
  96.  
  97. Starting and Stopping
  98.  
  99.    Start Snap with 'snap'. That's it. Snap detaches itself
  100.    from the CLI, making it possible to close the CLI.
  101.    Make sure that you have 'clipboard.device' in devs:.
  102.    To get rid of Snap, execute 'snap -Q' (or snap QUIT).
  103.    Note that you can't remove Snap if you have any 'snapped'
  104.    windows left.
  105.  
  106.  
  107. Command line arguments
  108.  
  109.    Snap accepts a couple of command line arguments. You can
  110.    use either unix or Amiga style arguments.
  111.    XX is hex. NN is decimal. str is a string.
  112.  
  113.    Usage:
  114.     snap -pNN -tXX -gXX -iXX -wXX -Pstr -Astr -cNN -lNN -aXXXX
  115.       -x -X -e -E -r -R -j -J -uN -bXX -oNN -CNN -BNN -Q
  116.     or
  117.     snap PRIORITY/k TEXTQUAL/k GFXQUAL/k INSERTKEY/k CWKEY/k
  118.       PREPEND/k APPEND/k CHARDELAY/k LINEDELAY/k CRAWLPTRN/k
  119.       XEROX/s NOXEROX/s EARLYPATCH/s NOEARLYPATCH/s STARTUNIT/k
  120.       TRUEUNDERSCORE/k FAKEUNDERSCORE/s JOINLONG/s NOJOINLONG/s
  121.       PLANEMASK/k GADOFFSET/k CACHESIZE/k BADCHAR/s QUIT/s
  122.  
  123.     -pNN
  124.     PRIORITY NN
  125.             where NN is the priority to use when installing
  126.             the input handler. Default is 51. Note that it's
  127.             not possible to change the priority of the input
  128.             handler while Snap is running.
  129.     -tXX
  130.     TEXTQUAL XX
  131.             where XX is the text qualifier to use in text
  132.             operations. Default is the left Amiga key.
  133.     -gXX
  134.     GFXQUAL XX
  135.             where XX is the graphics qualifier to use in
  136.             graphics operations. Default is the right Amiga key.
  137.     -iXX
  138.     INSERTKEY XX
  139.             where XX is the raw key code for the key to be used
  140.             together with the left Amiga key as insert key.
  141.             Use together with Shift to get modidified inserts.
  142.             Use 0 to disable. Default is hex 17 ("I").
  143.     -wXX
  144.     CWKEY XX
  145.             where XX is the raw key code for the key to be used
  146.             together with the left Amiga key to open the Snap
  147.             control window. Default is hex 11 ("W").
  148.     -Pstr
  149.     PREPEND str
  150.             where str is the string that will be inserted in
  151.             front of every line in a modified insert. Max
  152.             length of the string is 16. Default is "> ".
  153.     -Astr
  154.     APPEND str
  155.             where str is the string that will be inserted after
  156.             every line in a modified insert. Max length of the
  157.             string is 16. Default is "".
  158.     -cNN
  159.     CHARDELAY NN
  160.             where NN is the amount of time that Snap should
  161.             wait after each character inserted into the input
  162.             stream. Default is 0.
  163.     -lNN
  164.     LINEDELAY NN
  165.             where NN is the amount of time that Snap should
  166.             wait after each carriage return inserted into the
  167.             input stream. Default is 0.
  168.     -aXXXX
  169.     CRAWLPTRN XXXX
  170.             where XXXX is a 16 bit number that specifies the
  171.             pattern for the crawling ants. Use FFFF to turn
  172.             the crawling off. If you specify 0 as the crawl
  173.             pattern, Snap will use different patterns for
  174.             each snapping mode (box/char/word/line).
  175.             Default is 7777.
  176.     -x
  177.     XEROX
  178.             tells Snap to use Xerox style snapping instead.
  179.             The snapped text is inserted immediately it has
  180.             been snapped.
  181.     -X
  182.     NOXEROX
  183.             turns off Xerox style snapping.
  184.     -e
  185.     EARLYPATCH
  186.             tells Snap to patch dangerous functions as soon as
  187.             the text qualifier goes down. This is done automatically
  188.             when you use Xerox style snapping.
  189.     -E
  190.     NOEARLYPATCH
  191.             turns off early patching. This is default.
  192.     -j
  193.     JOINLONG
  194.             tells Snap to join long lines. This means that Snap
  195.             joins (removes the line feed between) two lines if
  196.             the first line has a non-blank in the last position.
  197.             This is not done in rectangular snapping.
  198.     -J
  199.     NOJOINLONG
  200.             disables the join-long-lines behavior. This is default.
  201.     -uN
  202.     STARTUNIT N
  203.             tells Snap which unit to use when you start snapping.
  204.             0 is rectangular snapping (FRAME).
  205.             1 is character snapping (CHAR). Default is 0.
  206.     -r
  207.     TRUEUNDERSCORE
  208.             tells Snap to do true checking of underscores when
  209.             snapping characters.
  210.     -R
  211.     FAKEUNDERSCORE
  212.             turns off true checking of underscores. Instead Snap
  213.             just skips the underscore line and hopes that the rest
  214.             of the character will provide correct matching. This
  215.             option is provided since there is a bug in the rendering
  216.             of underscored characters.
  217.     -bXX
  218.     PLANEMASK XX
  219.             where XX is the bit plane mask used when drawing the
  220.             selection frame for character snapping. This does not
  221.             affect graphics snapping. Default is 1.
  222.     -oNN
  223.     GADOFFSET NN
  224.             where NN is the offset for the save gadget. This may
  225.             be necessary to use if you use some kind of iconifier
  226.             program that puts a gadget where Snap usually puts the
  227.             save gadget. Default is 52.
  228.     -CNN
  229.     CACHESIZE NN
  230.             where NN is the number of windows that Snap will cache
  231.             character offsets for. Specifying a new value while Snap
  232.             is running means that you increase the cache size by N.
  233.             Default size is 10, default increase is 0.
  234.     -BNN
  235.     BADCHAR NN
  236.             where NN is the ascii value of the character that will
  237.             be used when Snap doesn't recognize a character.
  238.             Default is 63, a '?'.
  239.     -Q
  240.     QUIT
  241.             removes Snap.
  242.  
  243. QUALIFIERS (always entered in HEX)  (This list borrowed from Matt Dillon)
  244.  
  245.     0001    Left Shift
  246.     0002    Right Shift
  247.     0004    Caps Lock
  248.     0008    Control
  249.     0010    Left Alt
  250.     0020    Right Alt
  251.     0040    Left Amiga Key
  252.     0080    Right Amiga Key
  253.     0100    Numeric Key Pad Key (not useful)
  254.     0200    Repeat              (not useful)
  255.     0400    Interrupt           (not useful)
  256.     0800    Multibroadcast      (not useful)
  257.     1000    Middle Mouse Button (not normally implemented by intuition)
  258.     2000    Right Mouse Button
  259.     4000    Left Mouse Button
  260.  
  261.     Note: Combinations are allowed, in which case any one of the
  262.           elected qualifiers along with the left, right mouse button
  263.           will cause the appropriate action to occur.
  264.  
  265.    Some useful raw key codes:
  266.     17 I    seems to become the Amiga standard
  267.     34 V    for you Macintosh freaks
  268.     15 Y    good ol' Emacs
  269.  
  270.  
  271. Modified inserts
  272.  
  273.    Modified insert means that extra characters are added in front of
  274.    and after each line as it is inserted. The characters in front
  275.    are set via the -P/PREPEND command line argument, the characters
  276.    after via the -A/APPEND command line argument.
  277.    These strings can also be set from ARexx using the commands
  278.    'PREPEND newstring' and
  279.    'APPEND newstring'.
  280.    These commands should be addressed to Snap using the ARexx command
  281.    'ADDRESS SNAP'.
  282.    The old string is returned in the RESULT variable, provided that
  283.    'OPTIONS RESULTS' is given.
  284.    If no newstring is given then no change is made.
  285.    A small example:
  286.  
  287.     /* Change PREPEND and APPEND strings for my mail answering program */
  288.  
  289.     PARSE ARG ReplyTo
  290.  
  291.     OPTIONS RESULTS
  292.  
  293.     ADDRESS SNAP 'prepend' ReplyTo'>'
  294.     oldprepend = RESULT
  295.     ADDRESS SNAP 'append' ""
  296.     oldappend = RESULT
  297.  
  298.  
  299. Delays
  300.  
  301.    The character and line delay may be necessary with some programs
  302.    that can't handle the amount of characters the Snap insert into
  303.    the input stream. CygnusEd is known to have problems with this.
  304.    TxED and UEdit handles inserted characters very nicely.
  305.    The delay is specified in milliseconds, eg a value of 1000 gives
  306.    a delay of 1 second.
  307.  
  308.  
  309. Watch out for
  310.  
  311.    The Early Patch behavior may cause problems if you use the Left
  312.    Amiga key as the text qualifier together with MachII. What
  313.    happens is that MachII can't activate a new window when you do
  314.    a Left Amiga-M.
  315.    Underscored characters can give problems. Apart from the bug
  316.    mentioned above there's another problem. In some fonts the
  317.    underscore character (_) and an underscored space looks the
  318.    same. Snap tries to be smart and usually gets it right. The
  319.    algorithm used is the following:
  320.    An underscore/underscored space is interpreted as an underscored
  321.    space if the previous character was underscored, otherwise it's
  322.    interpreted as a true underscore character.
  323.  
  324.  
  325. Snapping
  326.  
  327.    Snapping comes in two flavors; characters and graphics.
  328.    Snapping graphics simply means that you can frame an
  329.    area on screen and that area is copied into a window.
  330.    Character snapping can be made in four different ways:
  331.    * rectangular snapping
  332.    * character oriented snapping
  333.    * word oriented snapping
  334.    * line oriented snapping
  335.  
  336.    Rectangular snapping makes it possible to snap a column
  337.    of text. A carriage return is inserted after each row,
  338.    except the last one.
  339.  
  340.    Line oriented snapping is much the same as rectangular
  341.    snapping, except that the width of the rectangle is the
  342.    width of the window.
  343.  
  344.    Character oriented snapping is much harder to explain than
  345.    to use. Character oriented snapping starts at one character,
  346.    extends to the right edge of the window, goes on with
  347.    complete lines, and ends at another character. The select box
  348.    can look like this: ________________________
  349.     __________________|                        |
  350.    |                                           |
  351.    |                 __________________________|
  352.    |________________|
  353.  
  354.    or like this:                      _________
  355.     _____                            |_________|
  356.    |_____|
  357.  
  358.    and of course like this:    ________________
  359.                               |________________|
  360.  
  361.    Word oriented snapping works the same way as character
  362.    oriented, except that you can only extend the selection
  363.    word by word. A word is defined as non-blanks surrounded
  364.    by blanks.
  365.  
  366.  
  367.    Let's define some actions used when controlling snap.
  368.  
  369.    CLICK
  370.       1. Press the mouse button.
  371.       2. Release the mouse button.
  372.  
  373.    MOVE
  374.       1. Move the mouse.
  375.  
  376.    PREPARE_TEXT
  377.       1. If you are using Xerox style snapping, make sure that your
  378.          intended destination window is active.
  379.       2. Press and hold the text qualifier (Default: Left Amiga key).
  380.       3. MOVE to the first character you want to copy.
  381.  
  382.    PREPARE_GFX
  383.       1. Press and hold the graphics qualifier (Default: Right Amiga key).
  384.       2. MOVE to the upper left corner of the area you want to copy
  385.  
  386.    EXTEND
  387.       1. MOVE
  388.       5. (Press and) Release the mouse button.
  389.  
  390.    END
  391.       1. Release the mouse button.
  392.       2. Release the qualifier.
  393.  
  394.    CANCEL
  395.       1. Release the qualifier.
  396.       2. Release the mouse button.
  397.  
  398.  
  399.    Ways to use these actions:
  400.    This is with starting unit FRAME. Selecting starting unit CHAR will
  401.    skip rectangular snapping and take you directly to character oriented
  402.    snapping. To do rectangular snapping you have to click through char,
  403.    word and line oriented back to rectangular snapping.
  404.  
  405.    To do rectangular snapping:
  406.     1. PREPARE_TEXT.
  407.     2. Press the left mouse button.
  408.     3. MOVE.
  409.     4. EXTEND until satisfied.
  410.     5. END or CANCEL.
  411.  
  412.    To do character oriented snapping
  413.     1. PREPARE_TEXT.
  414.     2. CLICK the left mouse button.
  415.     3. EXTEND until satisfied.
  416.     4. END or CANCEL.
  417.  
  418.    To do word oriented snapping
  419.     1. PREPARE_TEXT.
  420.     2. Double-CLICK left mouse button.
  421.     3. EXTEND until satisfied.
  422.     4. END or CANCEL.
  423.  
  424.    To do line oriented snapping
  425.     1. PREPARE_TEXT.
  426.     2. Triple-CLICK left mouse button.
  427.     3. EXTEND until satisfied.
  428.     4. END or CANCEL.
  429.  
  430.    To insert snapped characters (BKSYSBUF "You know ;-)")
  431.     1. PREPARE_TEXT.
  432.     2. CLICK the right mouse button.
  433.    or
  434.     1. Press and hold the left amiga key.
  435.     2. Type the insert key as specified with -i (Default "I").
  436.  
  437.    To insert snapped characters including prepend and append strings
  438.     1. Press and hold the left amiga key and either shift key.
  439.     2. Type the insert key as specified with -i (Default "I").
  440.  
  441.    To abort insertion
  442.     1. CLICK the left mouse button.
  443.  
  444.    To snap graphics
  445.     1. PREPARE_GFX.
  446.     2. Press the left mouse button.
  447.     3. MOVE.
  448.     4. EXTEND until satisfied.
  449.     5. END or CANCEL.
  450.  
  451.    To open the Snap Control Window
  452.     1. Press and hold the left amiga key.
  453.     2. Type the control window key as specified with -w (Default "W").
  454.  
  455.    When snapping text you can go directly from snapping to
  456.    inserting by replacing "END or CANCEL" above with
  457.    "Release left mouse button - CLICK right mouse button".
  458.    If you are using Xerox style snapping, the snapped text
  459.    will be inserted as soon as you END.
  460.    When selecting snapping unit a fourth click takes you
  461.    back to character oriented snapping. Each click steps
  462.    one unit. Note that rectangular snapping only is available
  463.    if you MOVE before you release the mouse button.
  464.  
  465.  
  466. Snapping characters, character coordinates and caching
  467.  
  468.    You must always start snapping at a character, otherwise
  469.    Snap won't get the coordinates right. This applies to all
  470.    kinds of snapping including line snapping.
  471.    Snap caches the character coordinates for the N last used
  472.    windows, where N is specified by the -C/CACHESIZE parameter.
  473.    When you start snapping in a window Snap checks it's cache
  474.    to see whether you have snapped in this window before.
  475.    If the window is in the cache then Snap first tries to find
  476.    a character at the previous coordinates. If no character is
  477.    found at the cached coordinates then Snap goes through the
  478.    complete lookup process. Of course this is transparent to
  479.    the user, so you don't have to worry about it. The size of
  480.    the cache can be specified by the user and is managed on a
  481.    Least Recently Used basis.
  482.    The caching makes it possible for Snap to get the correct
  483.    character coordinates even if you start snapping on a space,
  484.    provided that you've snapped in that window before.
  485.  
  486.    Trailing blanks are removed on each line when you're snapping
  487.    characters, words or lines, but not when doing rectangular
  488.    snapping. Trailing blanks are only removed in line mode if
  489.    you're snapping a single line.
  490.  
  491.  
  492. Snapping and Saving Graphics
  493.  
  494.    Windows with graphic snaps are always opened on the Workbench
  495.    screen. If you've snapped graphics from a screen with different
  496.    colors then you can switch to the graphic snap's original colors
  497.    by holding down the left mouse button inside the snap window.
  498.    Saving of graphics is done via the Snap Control Window (SCW).
  499.    To the left of a Snap window's window-to-front and window-to-back
  500.    gadgets is a small gadget that looks like a disk. Clicking this
  501.    disk gadget has different effects according to a two conditions.
  502.  
  503.      SCW        Graphics Window
  504.    not open      not selected     Opens the SCW, selects the Graphics Window
  505.      open        not selected     Selects the Graphics Window.
  506.      open          selected       Saves the contents of the Graphics Window
  507.  
  508.    The Snap Control Window looks something like this:
  509.     _______________________________
  510.    |x|Snap_Control_Window________|||
  511.    | ____      __________________  |
  512.    ||Save| as |Name gadget       | |
  513.    | ~~~~      ~~~~~~~~~~~~~~~~~~  |
  514.    | Transparent color |0~~|       |
  515.    |                    ~~~        |
  516.     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  517.    The Save gadget will be ghosted if no window is selected.
  518.    Clicking the Save gadget will save the contents of the
  519.    selected Graphics Window as an IFF file.
  520.    The Transparent color gadget is used to specify which color
  521.    will be transparent in the saved IFF file.
  522.    The Name gadget is used to specify the name of the IFF file
  523.    to save. The Name gadget is a string gadget if arp.library
  524.    isn't available. If arp.library is available it will be a
  525.    click-gadget that brings up an Arp File Requester.
  526.  
  527.  
  528. Compiling
  529.  
  530.    A 'makefile' is provided. Depending on which compiler you
  531.    use, remove and insert '#'s.
  532.    I seem to have some problem with the detaching when using
  533.    Lattice. Everything works ok, except that you can't close
  534.    the CLI-window. If anybody solves it, I'd be very grateful
  535.    to know about it.
  536.  
  537.  
  538. Some things to remember
  539.  
  540.    a. The text is sent to the active window. Make sure that
  541.       the correct window is active.
  542.    b. Don't interfere when the text is being inserted. Any key
  543.       pressed by you will be inserted in the middle of the text
  544.       being inserted.
  545.    c. Snap begins with an attempt to find the character coordinates.
  546.       Therefore if you begin snapping on a space, Snap will almost
  547.       certainly get the wrong coordinates, unless Snap has cached
  548.       the character coordinates from a previous snap.
  549.    d. To be able to do Xerox style snapping, Snap disables
  550.       ActivateWindow when the text qualifier is held down.
  551.       By doing this Snap makes sure that the destination window
  552.       remains active when you move out of it, even if you are
  553.       using DMouse or another Sun mouse utility.
  554.  
  555.  
  556. Bugs
  557.  
  558.    Of course, what did you think. Well, as far as I know there
  559.    are no explicit bugs. Oh yes, there is one that I don't know
  560.    how to solve. The problem is that some font editors optimize
  561.    the character image data. The result is that two characters
  562.    with the same image (e.g. I and l in some fonts) uses the
  563.    same image data, thereby making it impossible for Snap to
  564.    determine which character was printed in the first place.
  565.    This can be solved by editing the font so that each character
  566.    is unique.
  567.  
  568.  
  569. Acknowledgements
  570.  
  571.    Thanks to:
  572.  
  573.    o Amiga-Lorraine for the machine.
  574.    o Jim Mackraz for the keymap inverting code.
  575.    o Radical Eye Software for "minrexx".
  576.    o William Hawes for ARexx, WShell, ConMan, etc.
  577.    o Bjorn Knutsson, Dominic Giampal, Marc Boucher, Eddy Carroll
  578.      and Jonas Petersson for testing.
  579.    o All of you who has sent or will send comments, contributions
  580.      or questions.
  581.  
  582. Improvements
  583.  
  584.    I've been thinking about adding a way for programs to "register"
  585.    their windows with Snap so that Snap can let the program handle
  586.    the snapping by itself. As an example: Snapping an icon as text
  587.    doesn't make much sense, so the program displaying the icon
  588.    could take over and put the name of the file in the clipboard.
  589.    A character-mapped window could also benefit from this.
  590.  
  591.  
  592. s-mail: Mikael Karlsson
  593.         Lovsattersvagen 10
  594.         S-585 98  LINKOPING
  595.         SWEDEN
  596.  
  597. e-mail: micke@slaka.sirius.se
  598.         micke@slaka.UUCP
  599.         {mcvax|munnari|seismo}!sunic!liuida!slaka!micke
  600.  
  601. Phone:  +46-13 50479
  602.         +46-431 50623 (in the summer)
  603.