home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / JED / JED097-1.TAR / jed / lib / mutekeys.sl < prev    next >
Encoding:
Text File  |  1994-12-12  |  4.4 KB  |  195 lines

  1. %
  2. % Mute (Dead or accent) keys for JED.
  3. %
  4. %   To use this package, put a line like the following in your jed.rc
  5. %
  6. %    mute_set_mute_keys ("`'^");
  7. %
  8. %   Here, the keys `, ', and ^ will be mute keys.  That is, pressing one of 
  9. %   these followed by the character to accent will insert an accented 
  10. %   character in the buffer.   This affects only the local keymap.  Valid
  11. %
  12. %   Valid Mute keys are:  
  13. %      ^, ~, ', `, \d168 (ISO Diaeresis), \d180 (ISO Acute), and ".
  14.  
  15. define mute_insert_accent (wants_accent, ok_chars, maps_to)
  16. {
  17.    variable pos, ch;
  18.    
  19.    ch = maps_to[0];
  20.    if (wants_accent)
  21.      {
  22.     !if (input_pending (10)) 
  23.       {
  24.          message (strcat (char(ch), "-"));
  25.          update (0);
  26.       }
  27.     
  28.     ch = getkey ();
  29.     pos = is_substr (ok_chars, char (ch));
  30.     !if (pos)
  31.       {
  32.          beep ();
  33.          return;
  34.       }
  35.     pos--;
  36.     ch = maps_to[pos];
  37.      }
  38.    insert_char (ch);
  39. }
  40.  
  41. variable Mute_Acute = 0;
  42. variable Mute_ISOAcute = 0;
  43. variable Mute_Circumflex = 0;
  44. variable Mute_Grave = 0;
  45. variable Mute_Tilde = 0;
  46. variable Mute_Diaeresis = 0;
  47. variable Mute_ISODiaeresis = 0;
  48.  
  49. define mute_set_mute_keys (str)
  50. {
  51.    variable i;
  52.  
  53.    Mute_Acute = 0;
  54.    Mute_ISOAcute = 0;
  55.    Mute_Circumflex = 0;
  56.    Mute_Grave = 0;
  57.    Mute_Tilde = 0;
  58.    Mute_Diaeresis = 0;
  59.    Mute_ISODiaeresis = 0;
  60.    
  61.    _for (0, strlen(str) - 1, 1)
  62.      {
  63.     i = ();
  64.     switch (str[i])
  65.       {
  66.        case '\'':
  67.          local_setkey ("mute_keymap_39", "'");
  68.          Mute_Acute = 1;
  69.       }
  70.       {
  71.          %% Asciitilde would be better to acute accent, if included in keyboard
  72.        case '\d180':
  73.          local_setkey ("mute_keymap_180", "\d180");
  74.          Mute_ISOAcute = 1;
  75.       }
  76.       {
  77.        case '^':
  78.          local_setkey ("mute_keymap_94", "^");
  79.          Mute_Circumflex = 1;
  80.       }
  81.       {
  82.        case '`':
  83.          local_setkey ("mute_keymap_96", "`");
  84.          Mute_Grave = 1;
  85.       }
  86.       {
  87.        case '~':
  88.          local_setkey ("mute_keymap_126", "~");
  89.          Mute_Tilde = 1;
  90.       }
  91.       {
  92.        case '"':
  93.          local_setkey ("mute_keymap_34", "\"");
  94.          Mute_Diaeresis = 1;
  95.       }
  96.       {
  97.          %% ISOLatin 1 diaeresis would be better, if included in keyboard
  98.        case '\d168':
  99.          local_setkey ("mute_keymap_168", "\d168");
  100.          Mute_ISODiaeresis = 1;
  101.       }
  102.      }
  103. }
  104.  
  105.  
  106. define mute_keymap_39 () % ' map
  107. {
  108. #ifdef MSDOS OS2
  109.    variable ok_chars = "'Eeaiou";
  110.    variable maps_to  = "'\d144\d130\d160\d161\d162\d163";
  111. #else
  112.    variable ok_chars = "'AEIOUYaeiouy";
  113.    variable maps_to  =
  114.    "'\d193\d201\d205\d211\d218\d221\d225\d233\d237\d243\d250\d253";
  115. #endif   
  116.    mute_insert_accent (Mute_Acute, ok_chars, maps_to);
  117. }
  118.  
  119. define mute_keymap_180 () % \d180 map
  120. {
  121. #ifdef MSDOS OS2
  122.    variable ok_chars = "'Eeaiou";
  123.    variable maps_to  = "'\d144\d130\d160\d161\d162\d163";
  124. #else
  125.    variable ok_chars = "\d180AEIOUYaeiouy";
  126.    variable maps_to  =
  127.    "\d180\d193\d201\d205\d211\d218\d221\d225\d233\d237\d243\d250\d253";
  128. #endif   
  129.    mute_insert_accent (Mute_ISOAcute, ok_chars, maps_to);
  130. }
  131.  
  132. define mute_keymap_94 () % ^ map
  133. {
  134. #ifdef OS2 MSDOS
  135.    variable ok_chars = "^aeiou";
  136.    variable maps_to  = "^\d131\d136\d140\d147\d150";
  137. #else
  138.    variable ok_chars = "^aeiou";
  139.    variable maps_to  = "^\d226\d234\d238\d244\d251";
  140. #endif
  141.    mute_insert_accent (Mute_Circumflex, ok_chars, maps_to);
  142. }
  143.    
  144. define mute_keymap_96  % ` map
  145. {
  146. #ifdef OS2 MSDOS
  147.    variable ok_chars = "`aeiou";
  148.    variable maps_to  = "`\d133\d138\d141\d149\d151";
  149. #else
  150.    variable ok_chars = "`AEIOUaeiou";
  151.    variable maps_to  = 
  152.    "`\d192\d200\d204\d210\d217\d224\d232\d236\d242\d249";
  153. #endif
  154.    mute_insert_accent (Mute_Grave, ok_chars, maps_to);
  155. }
  156.  
  157. define mute_keymap_126  % ~ map
  158. {
  159. #ifdef MSDOS OS2
  160.    variable ok_chars = "~Nn";
  161.    variable maps_to  = "~\d165\d164";
  162. #else
  163.    variable ok_chars = "~NnAOao";
  164.    variable maps_to  = "~\d209\d241\d195\d213\d227\d245";
  165. #endif
  166.    mute_insert_accent (Mute_Tilde, ok_chars, maps_to);
  167. }
  168.  
  169. define mute_keymap_34  % \" map
  170. {
  171. #ifdef MSDOS OS2
  172.    variable ok_chars = "\"uaAeioyOU";
  173.    variable maps_to  = "\"\d129\d132\d142\d137\d139\d148\d152\d153\d154";
  174. #else
  175.    variable ok_chars = "\"AEIOUaeiouys";
  176.    variable maps_to  = 
  177.    "\"\d196\d203\d207\d214\d220\d228\d235\d239\d246\d252\d255\d223";
  178. #endif
  179.    mute_insert_accent (Mute_Diaeresis, ok_chars, maps_to);
  180. }
  181.  
  182. define mute_keymap_168  % \d168 map
  183. {
  184. #ifdef MSDOS OS2
  185.    variable ok_chars = "\"uaAeioyOU";
  186.    variable maps_to  = "\"\d129\d132\d142\d137\d139\d148\d152\d153\d154";
  187. #else
  188.    variable ok_chars = "\d168AEIOUaeiouy";
  189.    variable maps_to  = 
  190.    "\d168\d196\d203\d207\d214\d220\d228\d235\d239\d246\d252\d255";
  191. #endif
  192.    mute_insert_accent (Mute_ISODiaeresis, ok_chars, maps_to);
  193. }
  194.  
  195.