home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epm603a.zip / EPMMAC.ZIP / EKEYS.E < prev    next >
Text File  |  1994-12-09  |  8KB  |  272 lines

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