home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / xdme1820.lha / XDME / keycom.c < prev    next >
C/C++ Source or Header  |  1993-02-05  |  12KB  |  569 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     keycom.c
  5.  
  6.     DESCRIPTION
  7.     command interface for keyboard-control with key functions
  8.  
  9.     NOTES
  10.     for interface with [X]DME version < 1.70
  11.         all functions in this module make use of av[] (readonly)
  12.     extensively uses keyhashes.c
  13.  
  14.     BUGS
  15.     plenty - but where
  16.  
  17.     TODO
  18.  
  19.  
  20.     EXAMPLES
  21.  
  22.     description of the user-commands:
  23.  
  24.     the commands below might get other names;
  25.     if so, please update their descriptions according
  26.     to the names they are used in command.c
  27.  
  28. *!  KEYS:
  29. *!  ****
  30. *!
  31. *!  the following commands allow access to [X]DME's keymappings
  32. *!  that way it is possible for each user to create an individual
  33. *!  UI for "his" [X]DME, for "his" programming language and for
  34. *!  his wishes.
  35. *!
  36. *! >MAP   key command    (will be "MAP key command help")
  37. *! >UNMAP key
  38. *!
  39. *!    with these commands YOu can modify the keytable:
  40. *!    MAP adds or modifies an existing key-entry to the keytable
  41. *!    UNMAP deletes an existing key-entry
  42. *!
  43. *!    key consists of a set of QUALIFIERS, a "-" and one code-
  44. *!    specification (both case sensitive)
  45. *!    the qualifiers are:
  46. *!        s == any shift (caps-lock with alpha-keys)
  47. *!        c == control
  48. *!        a == any alt
  49. *!        A == any amiga
  50. *!        L == left mouse button
  51. *!        M == middle mouse button
  52. *!        R == right mouse button
  53. *!        u == key-up ( release of a key )
  54. *!        x == extended qualifier x
  55. *!        y == extended qualifier y
  56. *!        z == extended qualifier z
  57. *!
  58. *!    the code-specification is one out of:
  59. *!      main keyboard:
  60. *!        [single lowercase character] == the key on you main keyboard - that shows it
  61. *!        [single uppercase alpha]     == the key on .... but that means a set s-qualifier
  62. *!
  63. *!      numerik keypad:
  64. *!        nk0 .. nk9        == numerik keypad 0..9
  65. *!        nk+|nk-|nk*|nk/|nk. == numerik keypad +,-,*,/,.
  66. *!
  67. *!        there are two more key on yor numerik keypad
  68. *!        with american|british mapping they are used as nk( and nk)
  69. *!        with most european mappings they are used as nk[ and nk]
  70. *!        with canadian mapping they are used as nk@ and nk°
  71. *!        if there is a standart mapping, that does map these keys
  72. *!        in another way, they are NOT supported yet. (please mail)
  73. *!
  74. *!      other special keys:
  75. *!        f1 .. f10  == Function keys
  76. *!        hel        == help-key
  77. *!        esc        == escape
  78. *!        del        == delete
  79. *!        bac|bs     == backspace ( <- )
  80. *!        tab        == tabulator
  81. *!        ent        == enter
  82. *!        spc|spa    == spacebar
  83. *!        up|dow|rig|lef == cursor keys
  84. *!
  85. *!        lmb|mmb|rmb    == mouse buttons
  86. *!        mmo        == mouse movement with a mousebutton pressed
  87. *!
  88. *!    note that as mousebuttons can act for qualifiing as well as for
  89. *!    specifiing the specifiing mousebutton must also be qualifiing
  90. *!    e.g L-rmb should not work, but LR-rmb should
  91. *!
  92. *!    note that certain keys may be used as dead-keys;
  93. *!    keys that are deading when pressed without qualifiers
  94. *!    are not accessible with that keyboard-interface
  95. *!    e.g. on german keyboards there is a key "'" next to "\"
  96. *!         which cannot be accessed
  97. *!    on the other hand, if a key is deading on a qualified level,
  98. *!    but not when pressed without qualifiers, You can remap it
  99. *!    e.g on german keyboards alt-f is deading, but -f not, so
  100. *!        You can access a-f; and if You map a-f to any function,
  101. *!        It looses it deading function for [X]DME
  102. *!        EXAMPLE:  <alt-f> <a> creates something like "á"
  103. *!        after a "MAP a-f (NULL)" the same key-sequence
  104. *!        creates a normal "a"
  105. *!
  106. *!    note that map soon is to expect another parameter:
  107. *!        the help -string that conatins information 'bout the command
  108. *!
  109. *!    keys with the x|y|z-qualifiers set can not accessed immediately
  110. *!    first You must set the right extended qualifiers, then
  111. *!    You may press the remaining qualifiers and keys
  112. *!    these keys were introduced to allow something like the
  113. *!    CTL-X prefix of MicroEmacs
  114. *!
  115. *!    ATN! we check only up to three characters for code-specifiction
  116. *!        so e.g. -space is recognized as -spa some people
  117. *!        call this a feature, but in fact it is a BUG, as that
  118. *!        method avoids rexx-commands which start whose 3 first digits
  119. *!        are the same like a special key from being implicitely executed
  120. *!
  121. *! >QUALIFIER qualifierset
  122. *!
  123. *!    that command allows setting of certain qualifiers
  124. *!    independently to the qualifiers pressed manually on the keyboard
  125. *!    (see above) it is designed to allow multi-key-sequences
  126. *!
  127. *!    EXAMPLE:
  128. *!         MAP  c-x (QUALIFIER x)
  129. *!         MAP cx-a (SAVEOLD)
  130. *!        would cause the sequence <ctrl-x> <ctrl-a> calling SAVEOLD
  131. *!
  132. *! >KEYSAVE filename
  133. *!
  134. *!    save the keytable as a file that can be
  135. *!    read by KEYLOAD
  136. *!
  137. *! >KEYLOAD filename
  138. *!
  139. *!    clear the keytable and instead build a new
  140. *!    contents out of the file filename
  141. *!
  142. *!
  143. *!  KEYTABLES:
  144. *!  *********
  145. *!
  146. *!  the following commands do only make sense, if
  147. *!  You are using multiple keytables
  148. *!  at [X]DME's start a keytable called "default" is created;
  149. *!  for "normal" usage, that single strip may suffer.
  150. *!
  151. *!  Please note that the above MENU... commands apply to the
  152. *!  CURRENT keytable (and only to it)
  153. *!
  154. *! >USEKEYTABLE name
  155. *!
  156. *!    search for a certain keytable and use it as the current one
  157. *!
  158. *! >REMKEYTABLE
  159. *!
  160. *!    delete the current keytable, if it is not the only one
  161. *!
  162. *! >NEWKEYTABLE name
  163. *!
  164. *!    if there is already a keytable called name,
  165. *!        simply call USEKEYTABLE name
  166. *!    else create a new keytable called name and use it
  167. *!
  168. *!
  169.  
  170.     SEE ALSO
  171.     keyhashes.c keycodes.c keyaddes.c keycontrol.c
  172.  
  173.     INDEX
  174.  
  175.     HISTORY
  176.     14-Dec-92  b_null created
  177.     16-Dec-92  b_null some names updated & introduced currenthash
  178.  
  179. ******************************************************************************/
  180.  
  181. /**************************************
  182.         Includes
  183. **************************************/
  184. /* we do not need anythig else - I think */
  185. #include "defs.h"
  186.  
  187.  
  188. /**************************************
  189.         Globale Variable
  190. **************************************/
  191. Prototype void do_map        (void);
  192. Prototype void do_unmap     (void);
  193. Prototype void do_keyload   (void);
  194. Prototype void do_keysave   (void);
  195. Prototype void do_qualifier (void);
  196. Prototype char*keyspectomacro(char*);
  197.  
  198. Prototype void do_new_keytable (void);
  199. Prototype void do_del_keytable (void);
  200. Prototype void do_use_keytable (void);
  201.  
  202.  
  203. /**************************************
  204.       Interne Defines & Strukturen
  205. **************************************/
  206. /* nothing */
  207.  
  208. /**************************************
  209.         Interne Variable
  210. **************************************/
  211. /* nothing */
  212.  
  213. /**************************************
  214.        Interne Prototypes
  215. **************************************/
  216. /* nothing */
  217.  
  218. /*****************************************************************************
  219.  
  220.     NAME
  221.     do_map
  222.  
  223.     PARAMETER
  224.     void
  225.  
  226.     RESULT
  227.     -/-
  228.  
  229.     RETURN
  230.     void
  231.  
  232.     DESCRIPTION
  233.     command interface for keyhashes/mapkey
  234.  
  235.     NOTES
  236.     for interface with [X]DME version < 1.70
  237.  
  238.     BUGS
  239.  
  240.     EXAMPLES
  241.  
  242.     SEE ALSO
  243.     do_unmap keyhashes/mapkey
  244.  
  245.     INTERNALS
  246.  
  247.     HISTORY
  248.     14-Dec-92  b_null created
  249.  
  250. ******************************************************************************/
  251.  
  252. void do_map (void)
  253. {
  254.     mapkey ( currenthash(), GetArg(1), GetArg(2) );
  255. } /* do_map */
  256.  
  257.  
  258.  
  259. /*****************************************************************************
  260.  
  261.     NAME
  262.     do_unmap
  263.  
  264.     PARAMETER
  265.     void
  266.  
  267.     RESULT
  268.     -/-
  269.  
  270.     RETURN
  271.     void
  272.  
  273.     DESCRIPTION
  274.     command interface for keyhashes/unmapkey
  275.  
  276.     NOTES
  277.     for interface with [X]DME version < 1.70
  278.  
  279.     BUGS
  280.  
  281.     EXAMPLES
  282.  
  283.     SEE ALSO
  284.     do_map, keyhashes/unmapkey
  285.  
  286.     INTERNALS
  287.  
  288.     HISTORY
  289.     14-Dec-92  b_null created
  290.  
  291. ******************************************************************************/
  292.  
  293. void do_unmap (void)
  294. {
  295.     unmapkey ( currenthash(), GetArg(1) );
  296. } /* do_unmap */
  297.  
  298.  
  299.  
  300. /*****************************************************************************
  301.  
  302.     NAME
  303.     do_keysave
  304.  
  305.     PARAMETER
  306.     void
  307.  
  308.     RESULT
  309.     -/-
  310.  
  311.     RETURN
  312.     void
  313.  
  314.     DESCRIPTION
  315.     command interface for keyhashes/savemap
  316.  
  317.     NOTES
  318.     for interface with [X]DME version < 1.70
  319.  
  320.     BUGS
  321.  
  322.     EXAMPLES
  323.  
  324.     SEE ALSO
  325.     do_keyload, keyhashes/savemap
  326.  
  327.     INTERNALS
  328.  
  329.     HISTORY
  330.     14-Dec-92  b_null created
  331.  
  332. ******************************************************************************/
  333.  
  334. void do_keysave (void)
  335. {
  336.     keysave ( currenthash(), GetArg(1) );
  337. } /* do_keysave */
  338.  
  339.  
  340.  
  341. /*****************************************************************************
  342.  
  343.     NAME
  344.     do_keyload
  345.  
  346.     PARAMETER
  347.     void
  348.  
  349.     RESULT
  350.     -/-
  351.  
  352.     RETURN
  353.     void
  354.  
  355.     DESCRIPTION
  356.     command interface for keyhashes/loadmap
  357.  
  358.     NOTES
  359.     for interface with [X]DME version < 1.70
  360.  
  361.     BUGS
  362.  
  363.     EXAMPLES
  364.  
  365.     SEE ALSO
  366.     do_keysave, keyhashes/loadmap
  367.  
  368.     INTERNALS
  369.  
  370.     HISTORY
  371.     14-Dec-92  b_null created
  372.  
  373. ******************************************************************************/
  374.  
  375. void do_keyload (void)
  376. {
  377.     keyload ( currenthash(), GetArg(1) );
  378. } /* do_keyload */
  379.  
  380.  
  381.  
  382. /*****************************************************************************
  383.  
  384.     NAME
  385.     do_qualifier
  386.  
  387.     PARAMETER
  388.     void
  389.  
  390.     RESULT
  391.     -/-
  392.  
  393.     RETURN
  394.     void
  395.  
  396.     DESCRIPTION
  397.     command interface for keyaddes/qualifier
  398.  
  399.     NOTES
  400.     for interface with [X]DME version > 1.70
  401.  
  402.     BUGS
  403.  
  404.     EXAMPLES
  405.  
  406.     SEE ALSO
  407.     keyhashes/qualifier
  408.  
  409.     INTERNALS
  410.  
  411.     HISTORY
  412.     16 Dec 1992 b_null created
  413.  
  414. ******************************************************************************/
  415.  
  416. void do_qualifier (void)
  417. {
  418.     qualifier (GetArg(1));
  419. } /* do_qualifier */
  420.  
  421.  
  422. char * keyspectomacro (char * str)
  423. {
  424.     return (keyspec2macro(currenthash(), str));
  425. } /* keyspectomacro */
  426.  
  427.  
  428.  
  429. /*****************************************************************************
  430.  
  431.     NAME
  432.     do_new_keytable
  433.  
  434.     PARAMETER
  435.     void
  436.  
  437.     RESULT
  438.     -/-
  439.  
  440.     RETURN
  441.     void
  442.  
  443.     DESCRIPTION
  444.     command interface for keyaddes/qualifier
  445.  
  446.     NOTES
  447.     <never tested>
  448.  
  449.     BUGS
  450.     <none known>
  451.  
  452.     EXAMPLES
  453.  
  454.     SEE ALSO
  455.  
  456.     INTERNALS
  457.  
  458.     HISTORY
  459.     28 Jan 1993  b_null created
  460.  
  461. ******************************************************************************/
  462.  
  463. void do_new_keytable (void)
  464. {
  465.     Ep->keytable = new_keytable (GetArg(1), 1);
  466. } /* do_new_keytable */
  467.  
  468.  
  469.  
  470. /*****************************************************************************
  471.  
  472.     NAME
  473.     do_del_keytable
  474.  
  475.     PARAMETER
  476.     void
  477.  
  478.     RESULT
  479.     -/-
  480.  
  481.     RETURN
  482.     void
  483.  
  484.     DESCRIPTION
  485.     command interface for keyaddes/qualifier
  486.  
  487.     NOTES
  488.     <never tested>
  489.  
  490.     BUGS
  491.     <none known>
  492.  
  493.     EXAMPLES
  494.  
  495.     SEE ALSO
  496.  
  497.     INTERNALS
  498.  
  499.     HISTORY
  500.     28 Jan 1993  b_null created
  501.  
  502. ******************************************************************************/
  503.  
  504. void do_del_keytable (void)
  505. {
  506.     KEYTABLE * kt = currenthash ();
  507.     ED         * ep;
  508.  
  509.     for (ep = GetHead (&DBase); ep; ep = GetSucc (ep)) {
  510.     if (ep->keytable == kt) {
  511.         ep->keytable = NULL;
  512.     } /* if */
  513.     } /* for */
  514.  
  515.     delete_keytable (kt, 0);
  516. } /* do_del_keytable */
  517.  
  518.  
  519.  
  520. /*****************************************************************************
  521.  
  522.     NAME
  523.     do_use_keytable
  524.  
  525.     PARAMETER
  526.     void
  527.  
  528.     RESULT
  529.     -/-
  530.  
  531.     RETURN
  532.     void
  533.  
  534.     DESCRIPTION
  535.     command interface for keyaddes/qualifier
  536.  
  537.     NOTES
  538.     <never tested>
  539.  
  540.     BUGS
  541.     <none known>
  542.  
  543.     EXAMPLES
  544.  
  545.     SEE ALSO
  546.  
  547.     INTERNALS
  548.  
  549.     HISTORY
  550.     28 Jan 1993  b_null created
  551.  
  552. ******************************************************************************/
  553.  
  554. void do_use_keytable (void)
  555. {
  556.     KEYTABLE * kt = get_keytable (GetArg (1));
  557.  
  558.     if (kt) {
  559.     Ep->keytable = kt;
  560.     } /* if */
  561. } /* do_use_keytable */
  562.  
  563.  
  564.  
  565.  
  566. /******************************************************************************
  567. *****  ENDE keycom.c
  568. ******************************************************************************/
  569.