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