home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / editor / epmtools / epmmac / ekeys.e < prev    next >
Text File  |  1993-03-09  |  7KB  |  245 lines

  1. /*                    E      keys                       */
  2. /*                                                      */
  3. /* The enter and space bar keys have been defined to do */
  4. /* specific E3 syntax structures.                       */
  5.  
  6. compile if INCLUDING_FILE <> 'EXTRA.E'  -- Following only gets defined in the base
  7. compile if EVERSION >= '4.12'
  8. ;  Keyset selection is now done once at file load time, not every time
  9. ;  the file is selected.  And because the DEFLOAD procedures don't have to be
  10. ;  kept together in the macros (ET will concatenate all the DEFLOADs the
  11. ;  same way it does DEFINITs), we can put the DEFLOAD here where it belongs,
  12. ;  with the rest of the keyset function.  (what a concept!)
  13. ;
  14. defload
  15.    universal load_ext
  16. compile if EPM
  17.    universal load_var
  18. compile endif
  19.    if load_ext='E' then
  20.       keys   E_keys
  21.  compile if E_TABS <> 0
  22.   compile if EPM
  23.       if not (load_var // 2) then  -- 1 would be on if tabs set from EA EPM.TABS
  24.   compile endif
  25.       'tabs' E_TABS
  26.   compile if EPM
  27.       endif
  28.   compile endif
  29.  compile endif
  30.  compile if E_MARGINS <> 0
  31.   compile if EPM
  32.       if not (load_var%2 - 2*(load_var%4)) then  -- 2 would be on if tabs set from EA EPM.MARGINS
  33.   compile endif
  34.       'ma'   E_MARGINS
  35.   compile if EPM
  36.       endif
  37.   compile endif
  38.  compile endif
  39.    endif
  40. compile endif
  41.  
  42. compile if WANT_CUA_MARKING & EPM
  43.  defkeys e_keys clear
  44. compile else
  45.  defkeys e_keys
  46. compile endif
  47.  
  48. compile if EVERSION >= 5
  49. def space=
  50. compile else
  51. def ' '=
  52. compile endif
  53.    universal expand_on
  54.    if expand_on then
  55.       if  not e_first_expansion() then
  56.          keyin ' '
  57.       endif
  58.    else
  59.       keyin ' '
  60.    endif
  61.  compile if EVERSION >= '5.20'
  62.    undoaction 1, junk                -- Create a new state
  63.  compile endif
  64.  
  65. compile if ASSIST_TRIGGER = 'ENTER'
  66. def enter=
  67.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  68.    universal enterkey
  69.  compile endif
  70. compile else
  71. def c_enter=
  72.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  73.    universal c_enterkey
  74.  compile endif
  75. compile endif
  76.    universal expand_on
  77.  
  78. compile if EVERSION >= 5
  79.    if expand_on then
  80. compile else
  81.    if expand_on & not command_state() then
  82. compile endif
  83. compile if EVERSION >= '4.12'
  84.       if not e_second_expansion() then
  85. compile else
  86.       if e_second_expansion() then
  87.          call maybe_autosave()
  88.       else
  89. compile endif
  90. compile if ASSIST_TRIGGER = 'ENTER'
  91.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  92.          call enter_common(enterkey)
  93.  compile else
  94.          call my_enter()
  95.  compile endif
  96. compile else  -- ASSIST_TRIGGER
  97.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  98.          call enter_common(c_enterkey)
  99.  compile else
  100.          call my_c_enter()
  101.  compile endif
  102. compile endif -- ASSIST_TRIGGER
  103.       endif
  104.    else
  105. compile if ASSIST_TRIGGER = 'ENTER'
  106.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  107.       call enter_common(enterkey)
  108.  compile else
  109.       call my_enter()
  110.  compile endif
  111. compile else  -- ASSIST_TRIGGER
  112.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  113.       call enter_common(c_enterkey)
  114.  compile else
  115.       call my_c_enter()
  116.  compile endif
  117. compile endif -- ASSIST_TRIGGER
  118.    endif
  119.  
  120. /* Taken out, interferes with some people's c_enter. */
  121. ;def c_enter=   /* I like Ctrl-Enter to finish the comment field also. */
  122. ;   getline line
  123. ;   if pos('/*',line) then
  124. ;      if not pos('*/',line) then
  125. ;         end_line;keyin' */'
  126. ;      endif
  127. ;   endif
  128. ;   down;begin_line
  129.  
  130. def c_x=       /* Force expansion if we don't have it turned on automatic */
  131.    if not e_first_expansion() then
  132.       call e_second_expansion()
  133.    endif
  134. compile endif  -- EXTRA
  135.  
  136. compile if not EXTRA_EX or INCLUDING_FILE = 'EXTRA.E'  -- Following gets defined in EXTRA.EX if it's being used
  137. defproc e_first_expansion
  138.    /*  up;down */
  139.    retc=1
  140. compile if EVERSION >= 5
  141.    if .line then
  142. compile else
  143.    if .line and (not command_state()) then
  144. compile endif
  145.       getline line
  146.       line=strip(line,'T')
  147.       w=line
  148.       wrd=upcase(w)
  149.       if wrd='FOR' then
  150.          replaceline w' =  to'
  151.          insertline substr(wrd,1,length(wrd)-3)'endfor',.line+1
  152.          if not insert_state() then insert_toggle
  153.          endif
  154.          keyin ' '
  155.       elseif wrd='IF' then
  156.          replaceline w' then'
  157.          insertline substr(wrd,1,length(wrd)-2)'else',.line+1
  158.          insertline substr(wrd,1,length(wrd)-2)'endif',.line+2
  159.          if not insert_state() then insert_toggle
  160. compile if EVERSION >= '5.50'
  161.              call fixup_cursor()
  162. compile endif
  163.          endif
  164.          keyin ' '
  165.       elseif wrd='ELSEIF' then
  166.          replaceline w' then'
  167.          if not insert_state() then insert_toggle
  168. compile if EVERSION >= '5.50'
  169.              call fixup_cursor()
  170. compile endif
  171.          endif
  172.          keyin ' '
  173.       elseif wrd='WHILE' then
  174.          replaceline w' do'
  175.          insertline substr(wrd,1,length(wrd)-5)'endwhile',.line+1
  176.          if not insert_state() then insert_toggle
  177. compile if EVERSION >= '5.50'
  178.              call fixup_cursor()
  179. compile endif
  180.          endif
  181.          keyin ' '
  182.       elseif wrd='LOOP' then
  183.          replaceline w
  184.          insertline substr(wrd,1,length(wrd)-4)'endloop',.line+1
  185.          call einsert_line()
  186.          .col=.col+SYNTAX_INDENT
  187.       elseif wrd='DO' then
  188.          replaceline w
  189.          insertline substr(wrd,1,length(wrd)-2)'enddo',.line+1
  190.          call einsert_line()
  191.          .col=.col+SYNTAX_INDENT
  192.       else
  193.          retc=0
  194.       endif
  195.    else
  196.       retc=0
  197.    endif
  198.    return retc
  199.  
  200. defproc e_second_expansion
  201.    retc=1
  202.    if .line then
  203.       getline line
  204.       parse value line with wrd rest
  205.       firstword=upcase(wrd)
  206.       if firstword='FOR' then
  207.          /* do tabs to fields of pascal for statement */
  208.          parse value upcase(line) with a '='
  209.          if length(a)>=.col then
  210.             .col=length(a)+3
  211.          else
  212.             parse value upcase(line) with a 'TO'
  213.             if length(a)>=.col then
  214.                .col=length(a)+4
  215.             else
  216.                call einsert_line()
  217.                .col=.col+SYNTAX_INDENT
  218.             endif
  219.          endif
  220.       elseif firstword='IF' or firstword='ELSEIF' or firstword='WHILE' or firstword='LOOP' or firstword='DO' or firstword='ELSE' then
  221.          if pos('END'firstword, upcase(line)) then
  222.             retc = 0
  223.          else
  224.             call einsert_line()
  225.             .col=.col+SYNTAX_INDENT
  226.             if firstword='LOOP' | firstword='DO' then
  227.                insertline substr(line,1,.col-SYNTAX_INDENT-1)'end'lowcase(wrd), .line+1
  228.             endif
  229.          endif
  230.       elseif pos('/*',line) then
  231. ;     elseif substr(firstword,1,2)='/*' then  /*see speed requirements */
  232.          if not pos('*/',line) then
  233.             end_line;keyin' */'
  234.          endif
  235.          call einsert_line()
  236.       else
  237.          retc=0
  238.       endif
  239.    else
  240.       retc=0
  241.    endif
  242.    return retc
  243.  
  244. compile endif  -- EXTRA
  245.