home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / epmtex12.zip / TEXKEYS.E < prev   
Text File  |  1993-02-19  |  8KB  |  299 lines

  1. /*
  2. ╔════════════════════════════════════════════════════════════╗
  3. ║                    TeX-Keys  V1.2c                         ║
  4. ║                                                            ║
  5. ║  The enter and space bar keys have been defined to do      ║
  6. ║  specific TeX editing features.                            ║ 
  7. ║                                                            ║
  8. ║  by Jo Koenen                                              ║ 
  9. ║                                                            ║
  10. ╚════════════════════════════════════════════════════════════╝
  11. */
  12.  
  13. compile if EVERSION >= '4.12'
  14. ;  Keyset selection is now done once at file load time, not every time
  15. ;  the file is selected.  And because the DEFLOAD procedures don't have to be
  16. ;  kept together in the macros (ET will concatenate all the DEFLOADs the
  17. ;  same way it does DEFINITs), we can put the DEFLOAD here where it belongs,
  18. ;  with the rest of the keyset function.  (what a concept!)
  19. ;
  20.  
  21. defload
  22. compile if EPM
  23.    universal load_var
  24.  compile endif
  25.    ext = filetype()
  26.  compile if defined(MY_TEX_FILE_TYPE)
  27.    if substr(ext,1,3)='TEX' or ext='STY' or ext='BBL' or ext=MY_TEX_FILE_TYPE then
  28.  compile else
  29.    if substr(ext,1,3)='TEX' or ext='STY' or ext='BBL' then
  30.  compile endif
  31.       keys   TEX_keys
  32.   compile if TEX_TABS <> 0
  33.   compile if EPM
  34.       if not (load_var // 2) then  -- 1 would be on if tabs set from EA EPM.TABS
  35.   compile endif
  36.       'tabs' TEX_TABS
  37.   compile if EPM
  38.       endif
  39.   compile endif
  40.  compile endif
  41.  compile if TEX_MARGINS <> 0
  42.   compile if EPM
  43.       if not (load_var%2 - 2*(load_var%4)) then  -- 2 would be on if tabs set from EA EPM.MARGINS
  44.   compile endif
  45.       'ma'   TEX_MARGINS
  46.   compile if EPM
  47.       endif
  48.   compile endif
  49.  compile endif
  50.    endif
  51. compile endif
  52.  
  53. compile if WANT_CUA_MARKING & EPM
  54.  defkeys tex_keys clear
  55. compile else
  56.  defkeys tex_keys
  57. compile endif
  58.  
  59. compile if EVERSION >= 5
  60. def space=
  61. compile else
  62. def ' '=
  63. compile endif
  64.    universal expand_on
  65.    if expand_on then
  66.       if  not tex_first_expansion() then
  67.          keyin ' '
  68.       endif
  69.    else
  70.       keyin ' '
  71.    endif
  72.  compile if EVERSION >= '5.20'
  73.    undoaction 1, junk                -- Create a new state
  74.  compile endif
  75.  
  76. compile if ASSIST_TRIGGER = 'ENTER'
  77. def enter=
  78.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''  
  79.    universal enterkey
  80.  compile endif
  81. compile else
  82. def c_enter=
  83.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''  
  84.    universal c_enterkey
  85.  compile endif
  86. compile endif
  87.    universal expand_on
  88.  
  89. compile if EVERSION >= 5
  90.    if expand_on then
  91. compile else
  92.    if expand_on & not command_state() then
  93. compile endif
  94. compile if EVERSION <= '4.12'
  95.       if tex_second_expansion() then
  96.          call maybe_autosave()
  97.       else
  98. compile else
  99.       if not tex_second_expansion() then
  100. compile endif
  101. compile if ASSIST_TRIGGER = 'ENTER'
  102.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''  
  103.          call enter_common(enterkey)
  104.  compile else
  105.          call my_enter()
  106.  compile endif
  107. compile else  -- ASSIST_TRIGGER
  108.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''  
  109.          call enter_common(c_enterkey)
  110.  compile else
  111.          call my_c_enter()
  112.  compile endif
  113. compile endif -- ASSIST_TRIGGER
  114.       endif
  115.    else
  116. compile if ASSIST_TRIGGER = 'ENTER'
  117.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''  
  118.       call enter_common(enterkey)
  119.  compile else
  120.       call my_enter()
  121.  compile endif
  122. compile else  -- ASSIST_TRIGGER
  123.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''  
  124.       call enter_common(c_enterkey)
  125.  compile else
  126.       call my_c_enter()
  127.  compile endif
  128. compile endif -- ASSIST_TRIGGER
  129.    endif
  130.  
  131.  
  132. -------------------------------------------------------------------------------
  133. -- Keyboard accelerators definitions for TeX
  134.  
  135.  
  136. compile if TEX_WANT_ACCELERATOR_KEYS  -- some people may not want the new key defs
  137.  
  138. def c_x=       /* Force expansion if we don't have it turned on automatic */
  139.    if not tex_first_expansion() then
  140.       call tex_second_expansion()
  141.    endif
  142.  
  143. def a_a= 
  144.    getline line
  145.    line_l=substr(line,1,.col-1)
  146.    line_r=substr(line,.col)
  147.    replaceline line_l'eqnarray'line_r
  148.    .col=.col+8
  149.  
  150. def a_b = 
  151.    getline line
  152.    line_l=substr(line,1,.col-1)
  153.    line_r=substr(line,.col)
  154.    replaceline line_l'\begin{} \end{}'line_r
  155.    .col=.col+7
  156.  
  157. def a_c = 
  158.    getline line
  159.    line_l=substr(line,1,.col-1)
  160.    line_r=substr(line,.col)
  161.    replaceline line_l'\cite{}'line_r
  162.    .col=.col+6
  163.  
  164. def a_f = 
  165.    getline line
  166.    line_l=substr(line,1,.col-1)
  167.    line_r=substr(line,.col)
  168.    replaceline line_l'\frac{}{}'line_r
  169.    .col=.col+6
  170.  
  171. def a_i = 
  172.    getline line
  173.    line_l=substr(line,1,.col-1)
  174.    line_r=substr(line,.col)
  175.    replaceline line_l'itemize'line_r
  176.    .col=.col+7
  177.  
  178. def a_l = 
  179.    getline line
  180.    line_l=substr(line,1,.col-1)
  181.    line_r=substr(line,.col)
  182.    replaceline line_l'\label{}'line_r
  183.    .col=.col+7
  184.  
  185. def a_m = 
  186.    getline line
  187.    line_l=substr(line,1,.col-1)
  188.    line_r=substr(line,.col)
  189.    replaceline line_l'\mbox{}'line_r
  190.    .col=.col+6
  191.  
  192. def a_q = 
  193.    getline line
  194.    line_l=substr(line,1,.col-1)
  195.    line_r=substr(line,.col)
  196.    replaceline line_l'equation'line_r
  197.    .col=.col+8
  198.  
  199. def a_r=
  200.    getline line
  201.    line_l=substr(line,1,.col-1)
  202.    line_r=substr(line,.col)
  203.    replaceline line_l'\begin{tabular}{|c|}'line_r
  204.    insertline '\end{tabular}',.line+1
  205.    .col=.col+19
  206.  
  207. def '{'= 
  208.    getline line
  209.    line_l=substr(line,1,.col-1)
  210.    line_r=substr(line,.col)
  211.    replaceline line_l'{}'line_r
  212.    .col=.col+1
  213.  
  214. def '$'= 
  215.    getline line
  216.    line_l=substr(line,1,.col-1)
  217.    line_r=substr(line,.col)
  218.    replaceline line_l'$$'line_r
  219.    .col=.col+1
  220.  
  221. compile endif
  222.  
  223. -------------------------------------------------------------------------------
  224. -- Syntax expansion code
  225.  
  226.  
  227. defproc tex_first_expansion
  228.    retc=1
  229. compile if EVERSION >= 5
  230.    if .line then
  231. compile else
  232.    if .line and (not command_state()) then
  233. compile endif
  234.       getline line
  235.       line=strip(line,'T')
  236.       line_l=substr(line,1,.col-1)
  237.       line_r=substr(line,.col)
  238.       linelen=length(line_l)
  239.       if linelen > 2 then
  240.           wrd=substr(line_l,.col-3,3)
  241.       else
  242.           wrd=line_l
  243.       endif
  244.       if wrd='\be' then
  245.          replaceline line_l'gin{}'line_r
  246.          if not insert_state() then insert_toggle 
  247. compile if EVERSION >= '5.50'
  248.              call fixup_cursor()
  249. compile endif
  250.          endif
  251.          .col=.col+4
  252.       elseif wrd='\it' then
  253.          replaceline line_l'em 'line_r
  254.          if not insert_state() then insert_toggle 
  255. compile if EVERSION >= '5.50'
  256.              call fixup_cursor()
  257. compile endif
  258.          endif
  259.          .col=.col+3
  260.       elseif wrd='\ci' then
  261.          replaceline line_l'te{}'line_r
  262.          if not insert_state() then insert_toggle 
  263. compile if EVERSION >= '5.50'
  264.              call fixup_cursor()
  265. compile endif
  266.          else
  267.          endif
  268.          .col=.col+3
  269.       else
  270.           retc=0
  271.       endif
  272.    else
  273.       retc=0
  274.    endif
  275.    return retc
  276.  
  277. defproc tex_second_expansion
  278.    retc=1
  279.    if .line then
  280.       getline lin
  281.       if (.col - 19) < 0 then
  282.          b=1
  283.       else b=.col-19
  284.       endif
  285.       line=substr(lin,b,.col-b)
  286.       parse value line with '\'wrd'{'texword'}'
  287.       if wrd='begin' then
  288.          insertline '\end{'texword'}',.line+1
  289.              call einsert_line()
  290.       else
  291.          retc=0
  292.       endif
  293.    else
  294.       retc=0
  295.    endif
  296.    return retc
  297.  
  298.  
  299.