home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / textedit / accent14.zip / ACCENT14.S < prev    next >
Text File  |  1993-07-30  |  7KB  |  185 lines

  1. /**************** Foreign-Character Macros **************************
  2.  
  3.   For TSE (The Semware Editor), pre-release version 1.0
  4.  
  5.   Author:  David Mayerovitch
  6.            reachable in ILink Qedit conference
  7.            or by E-mail: david.mayerovitch@canrem.com
  8.  
  9.            macro version 1.0 07 June 1993
  10.            macro version 1.1 12 June 1993
  11.            - added Spanish, more French characters
  12.            - removed International
  13.            macro version 1.2 15 June 1993
  14.            - added Spanish ordinals
  15.            macro version 1.3 20 June 1993
  16.            - macro source code uses Chr() notation rather than
  17.              character literals to preserve valid code if this
  18.              text should somehow pass through a high-ASCII filter
  19.            - minor documentation errors fixed
  20.            macro version 1.4 28 July 1993
  21.            - renamed "umlaut" in French menu
  22.              to the correct "tréma" (thanks to Thomas Taylor)
  23.            - renamed global variable "language" to "lng"
  24.              to remove conflict with TSE variable "language"
  25.            - minor doc mods
  26.  
  27.   The documentation portion of this text contains high-ASCII
  28.   characters which will not appear correctly if the file reaches you
  29.   after somehow passing through a high-ASCII filter.  However, in the
  30.   actual source code below, the Chr() notation ensures correct
  31.   compilation and functioning of the macro.
  32.   -------------------
  33.  
  34.   This pair of macros provides a quick and convenient way of entering
  35.   foreign-language and other special characters.
  36.  
  37.   mSelectLanguage() presents a menu of languages or other
  38.   special-character sets for the user to choose from. I have assigned
  39.   this macro to <Alt `>.
  40.  
  41.   mAccenter() enables the entry of the special characters belonging to
  42.   the selected set.  I have assigned this macro to the key <`>. Call
  43.   this the trigger key.
  44.  
  45.   These macros do what you do when writing foreign characters by hand:
  46.   first write the basic letterform, then add the diacritical mark.
  47.   Example: If the selected language is French and you want to enter
  48.   the character <é> (e with accent aigu): type the basic character <e>,
  49.   then press the trigger key.  A pop-up menu appears:
  50.  
  51.   ┌──────────┐
  52.   │ Aigu   é │
  53.   │ Grave  è │
  54.   │ Circ   ê │
  55.   │ Tréma  ë │
  56.   └──────────┘
  57.  
  58.   The hotkeys A, G, C, and T generate the four possible e-based
  59.   accented characters in French. Press <A> and the <e> just
  60.   typed will be replaced with <é>.
  61.  
  62.   When there is only one possible accented version of the character
  63.   just typed (e.g. ü in German), the macro automatically inserts it
  64.   without popping up a menu.
  65.  
  66.   The macros as presented here offer the following character sets:
  67.   French: à â ç Ç é è ê ë É î ï ô ù û
  68.   German: ä Ä ö Ö ü Ü
  69.   Spanish: á ª é í ó º ú ñ Ñ ¿ ¡
  70.   Currency: c/C --> ¢ (cents)  l/L --> £ (pounds)  y/Y --> ¥ (yen)
  71.  
  72.   Note that in the Spanish set you may generate the <¿> by entering
  73.   either <?> or its unshifted key-mate </>, then pressing the trigger
  74.   key.  Similarly either <!> or <1> (top row, not keypad) may be used
  75.   to generate <¡>.
  76.  
  77.   French is the default: it is automatically selected when the macro
  78.   is loaded.  Change the default by changing the global variable
  79.   lng (see macro source below).
  80.  
  81.   You may easily edit the macros to provide any substitutions you
  82.   want.  Strings as well as single characters may be substituted: the
  83.   string "integer" could be expanded from "i", or your name from your
  84.   initial.  Modify the language menu to provide character sets of your
  85.   choice - math, Greek, graphics, and so on.
  86.  
  87.   If you have occasional need for characters from different languages,
  88.   you might group them into a single International set rather than
  89.   switching languages.  The tradeoff would be that you'd have fewer
  90.   automatic substitutions and more menu choices.
  91.  
  92.   If a printable key such as <`> is chosen as the trigger for
  93.   mAccenter(), the Literal() command (assigned to <Ctrl P> in the
  94.   factory configuration of TSE) may be used whenever the character
  95.   itself is required in the text.
  96.  
  97.   Comments and improvements are welcome.
  98.  
  99. ********************************************************************/
  100. // MACRO SOURCE CODE
  101.  
  102. integer lng = 1 // French is default (make it 3 for Spanish)
  103.  
  104. // LANGUAGE SELECTION ROUTINES:
  105. menu langMenu() history
  106.   '&French'  '&German'   '&Spanish' '', , Divide  '&Currency'
  107. end
  108. proc mSelectLanguage()
  109.   langMenu()  lng = MenuOption()
  110. end
  111.  
  112. // CHARACTER SUBSTITUTION ROUTINES:
  113. proc sub(string newstring)
  114. // replaces current char by newstring, forcing insert.
  115.   DelChar()  InsertText(newstring,_insert_)
  116. end
  117.  
  118. menu FrenchAMenu()
  119.   '&Grave '+Chr(133), sub(Chr(133))
  120.   '&Circ  '+Chr(131), sub(Chr(131)) end
  121. menu FrenchEMenu()
  122.   '&Aigu   '+Chr(130), sub(Chr(130))
  123.   '&Grave  '+Chr(138), sub(Chr(138))
  124.   '&Circ   '+Chr(136), sub(Chr(136))
  125.   '&Tréma  '+Chr(137), sub(Chr(137)) end
  126. menu FrenchIMenu()
  127.   '&Circ   '+Chr(140), sub(Chr(140))
  128.   '&Tréma  '+Chr(139), sub(Chr(139)) end
  129. menu FrenchUMenu()
  130.   '&Grave  '+Chr(151), sub(Chr(151))
  131.   '&Circ   '+Chr(150), sub(Chr(150)) end
  132. menu SpanishOMenu()
  133.   '&Accent  '+Chr(162), sub(Chr(162))
  134.   '&Ordinal '+Chr(167), sub(Chr(167)) end
  135. menu SpanishAMenu()
  136.   '&Accent  '+Chr(160), sub(Chr(160))
  137.   '&Ordinal '+Chr(166), sub(Chr(166)) end
  138.  
  139. proc French()
  140.   case Chr(CurrChar())
  141.     when 'a' FrenchAMenu() when 'e' FrenchEMenu()
  142.     when 'i' FrenchIMenu() when 'u' FrenchUMenu()
  143.     when 'E' sub(Chr(144)) when 'c' sub(Chr(135))
  144.     when 'C' sub(Chr(128))
  145.     when 'i' sub(Chr(140)) when 'o' sub(Chr(147))
  146.     otherwise Right() endcase
  147. end
  148. proc German()
  149.   case Chr(CurrChar())
  150.     when 'a' sub(Chr(132)) when 'A' sub(Chr(142))
  151.     when 'o' sub(Chr(148)) when 'O' sub(Chr(153))
  152.     when 'u' sub(Chr(129)) when 'U' sub(Chr(154))
  153.     otherwise Right() endcase
  154. end
  155. proc Spanish()
  156.   case Chr(CurrChar())
  157.     when 'a' SpanishAMenu() when 'o' SpanishOMenu()
  158.     when 'e' sub(Chr(130)) when 'i' sub(Chr(161))
  159.     when 'u' sub(Chr(163)) when 'n' sub(Chr(164))
  160.     when 'N' sub(Chr(165))
  161.     when '?' sub(Chr(168)) when '/' sub(Chr(168))
  162.                           // unshifted ? key
  163.     when '!' sub(Chr(173)) when '1' sub(Chr(173))
  164.                           // unshifted ! key
  165.     otherwise Right() endcase
  166. end
  167. proc Currency()
  168.   case UpCase(Chr(CurrChar()))
  169.     when 'C' sub(Chr(155)) // cents
  170.     when 'L' sub(Chr(156)) // pounds
  171.     when 'Y' sub(Chr(157)) // yen
  172.     otherwise Right() endcase
  173. end
  174.  
  175. proc mAccenter()
  176.   Left()
  177.   Case lng
  178.     when 1 French() when 2 German() when 3 Spanish()
  179.     when 5 Currency()
  180.     endcase
  181. end
  182. <`> mAccenter()
  183. <Alt `> mSelectLanguage()
  184. /************************** End of macros **************************/
  185.