home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / epmmac2.zip / REXXKEYS.E < prev    next >
Text File  |  1993-01-07  |  6KB  |  195 lines

  1. /**********************************************************************/
  2. /*                             REXKEYS.E                              */
  3. /*                                                                    */
  4. /* The c_enter and space bar keys have been defined to do specific    */
  5. /* REXX syntax structures.                                            */
  6. /*                                                                    */
  7. /* Based on EKEYS.E (part of the base E3 code)                        */
  8. /* Written by B. Thompson, 22 Sep 1987                                */
  9. /*                                                                    */
  10. /**********************************************************************/
  11. /*  Updated by Larry Margolis for EOS2 and EPM.  To include, set in   */
  12. /*  your MYCNF.E:   REXX_SYNTAX_ASSIST = 1                            */
  13. /*                                                                    */
  14. /**********************************************************************/
  15.  
  16. compile if EVERSION >= '4.12'
  17. defload
  18.    universal load_ext
  19. compile if EPM
  20.    universal load_var
  21. compile endif
  22.    if load_ext='BAT' | load_ext='CMD' | load_ext='EXC' | load_ext='EXEC' | load_ext='XEDIT' | load_ext='ERX' then
  23.       getline line,1
  24.       if substr(line,1,2)='/*' or (line='' & .last = 1) then
  25.          keys   rexx_keys
  26.  compile if REXX_TABS <> 0
  27.   compile if EPM
  28.          if not (load_var // 2) then  -- 1 would be on if tabs set from EA EPM.TABS
  29.   compile endif
  30.          'tabs' REXX_TABS
  31.   compile if EPM
  32.          endif
  33.   compile endif
  34.  compile endif
  35.  compile if REXX_MARGINS <> 0
  36.   compile if EPM
  37.          if not (load_var%2 - 2*(load_var%4)) then  -- 2 would be on if tabs set from EA EPM.MARGINS
  38.   compile endif
  39.          'ma'   REXX_MARGINS
  40.   compile if EPM
  41.          endif
  42.   compile endif
  43.  compile endif
  44.       endif
  45.    endif
  46. compile endif
  47.  
  48. compile if WANT_CUA_MARKING & EPM
  49.  defkeys rexx_keys clear
  50. compile else
  51.  defkeys rexx_keys
  52. compile endif
  53.  
  54. compile if EVERSION >= 5
  55. def space=
  56. compile else
  57. def ' '=
  58. compile endif
  59.    universal expand_on
  60.    if expand_on then
  61.       if not rex_first_expansion() then
  62.          keyin ' '
  63.       endif
  64.    else
  65.       keyin ' '
  66.    endif
  67.  compile if EVERSION >= '5.20'
  68.    undoaction 1, junk                -- Create a new state
  69.  compile endif
  70.  
  71. compile if ASSIST_TRIGGER = 'ENTER'
  72. def enter=
  73.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  74.    universal enterkey
  75.  compile endif
  76. compile else
  77. def c_enter=
  78.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  79.    universal c_enterkey
  80.  compile endif
  81. compile endif
  82.    universal expand_on
  83.  
  84. compile if EVERSION >= 5
  85.    if expand_on then
  86. compile else
  87.    if expand_on & not command_state() then
  88. compile endif
  89. compile if EVERSION >= '4.12'
  90.       if not rex_second_expansion() then
  91. compile else
  92.       if rex_second_expansion() then
  93.          call maybe_autosave()
  94.       else
  95. compile endif
  96. compile if ASSIST_TRIGGER = 'ENTER'
  97.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  98.          call enter_common(enterkey)
  99.  compile else
  100.          call my_enter()
  101.  compile endif
  102. compile else  -- ASSIST_TRIGGER
  103.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  104.          call enter_common(c_enterkey)
  105.  compile else
  106.          call my_c_enter()
  107.  compile endif
  108. compile endif -- ASSIST_TRIGGER
  109.       endif
  110.    else
  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.  
  126. def c_x=       -- Force expansion if we don't have it turned on automatic
  127.    if not rex_first_expansion() then
  128.       call rex_second_expansion()
  129.    endif
  130.  
  131. defproc rex_first_expansion            -- Called by space bar
  132.    retc = 0                            -- Default, enter a space
  133. compile if EVERSION >= 5
  134.    if .line then
  135. compile else
  136.    if .line and (not command_state()) then
  137. compile endif
  138.       w=strip(textline(.line),'T')
  139.       wrd=upcase(w)
  140.       If wrd='IF' Then
  141.          replaceline w' then'
  142.          insertline substr(wrd,1,length(wrd)-2)'else',.line+1
  143.          if not insert_state() then insert_toggle
  144. compile if EVERSION >= '5.50'
  145.              call fixup_cursor()
  146. compile endif
  147.          endif
  148.       elseif wrd='WHEN' Then
  149.          replaceline w' then'
  150.          if not insert_state() then insert_toggle
  151. compile if EVERSION >= '5.50'
  152.              call fixup_cursor()
  153. compile endif
  154.          endif
  155.       elseif wrd='DO' Then
  156.          insertline substr(wrd,1,length(wrd)-2)'end /* do */',.line+1
  157. ;        if not insert_state() then insert_toggle endif
  158.       endif
  159.    endif
  160.    return retc
  161.  
  162. defproc rex_second_expansion
  163.    retc=1                               -- Default, don't insert a line
  164.    if .line then
  165.       getline line
  166.       line = upcase(line)
  167.       parse value line with firstword .
  168.       c=max(1,verify(line,' '))-1  -- Number of blanks before first word.
  169.  
  170.       If firstword='SELECT' then
  171.          insertline substr('',1,c+SYNTAX_INDENT)'when',.line+1
  172.          insertline substr('',1,c /*+SYNTAX_INDENT*/)'otherwise',.line+2
  173.          insertline substr('',1,c)'end  /* select */',.line+3
  174.          '+1'                             -- Move to When clause
  175.          .col = c+SYNTAX_INDENT+5         -- Position the cursor
  176.       Elseif firstword = 'DO' then
  177.          call einsert_line()
  178.          .col=.col+SYNTAX_INDENT
  179.       Elseif Pos('THEN DO',line) > 0 or Pos('ELSE DO',line) > 0 Then
  180.          call einsert_line()
  181.          .col=.col+SYNTAX_INDENT
  182.          insertline substr('',1,c)'end  /* Do */',.line+1
  183. ;     Elseif pos('/*',line) then          -- Annoying to me, as I don't always
  184. ;        if not pos('*/',line) then       -- want a comment closed on that line
  185. ;           end_line;keyin' */'           -- Enable if you wish by uncommenting
  186. ;        endif
  187. ;        call einsert_line()
  188.       Else
  189.          retc = 0                         -- Insert a blank line
  190.       Endif
  191.    Else
  192.       retc=0
  193.    Endif
  194.    Return(retc)
  195.