home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / CKEYS.E < prev    next >
Text File  |  1996-02-06  |  21KB  |  643 lines

  1. /*                    C keys                            */
  2. /*                                                      */
  3. /* The enter and space bar keys have been defined to do */
  4. /* specific C editing features.                         */
  5.  
  6. CONST
  7. compile if not defined(I_like_my_cases_under_my_switch)
  8.    I_like_my_cases_under_my_switch = 1
  9. compile endif
  10. compile if not defined(I_like_a_semicolon_supplied_after_default)
  11.    I_like_a_semicolon_supplied_after_default = 0
  12. compile endif
  13. compile if not defined(ADD_BREAK_AFTER_DEFAULT)
  14.    ADD_BREAK_AFTER_DEFAULT = 1
  15. compile endif
  16. compile if not defined(WANT_BRACE_BELOW_STATEMENT)
  17.    WANT_BRACE_BELOW_STATEMENT = 0
  18. compile endif
  19. compile if not defined(WANT_BRACE_BELOW_STATEMENT_INDENTED)
  20.    WANT_BRACE_BELOW_STATEMENT_INDENTED = 0
  21. compile endif
  22. compile if not defined(USE_ANSI_C_NOTATION)
  23.    USE_ANSI_C_NOTATION = 1  -- 1 means use shorter ANSI C notation on MAIN.
  24. compile endif
  25. compile if not defined(TERMINATE_COMMENTS)
  26.    TERMINATE_COMMENTS = 0
  27. compile endif
  28. compile if not defined(C_KEYWORD_HIGHLIGHTING)
  29.    C_KEYWORD_HIGHLIGHTING = 0
  30. compile endif
  31. compile if not defined(JAVA_KEYWORD_HIGHLIGHTING)
  32.    JAVA_KEYWORD_HIGHLIGHTING = 0
  33. compile endif
  34. compile if not defined(WANT_END_COMMENTED)
  35.  compile if defined(WANT_END_BRACE_COMMENTED)
  36.    WANT_END_COMMENTED = WANT_END_BRACE_COMMENTED
  37.  compile else
  38.    WANT_END_COMMENTED = 1
  39.  compile endif
  40. compile endif
  41. compile if not defined(JAVA_SYNTAX_ASSIST)
  42.    JAVA_SYNTAX_ASSIST = 0
  43. compile endif
  44.  
  45. compile if not defined(C_SYNTAX_INDENT)
  46.    C_SYNTAX_INDENT = SYNTAX_INDENT
  47. compile endif
  48.  
  49. compile if not defined(C_EXTENSIONS)  -- Keep in sync with TAGS.E
  50.    C_EXTENSIONS = 'C H SQC'
  51. compile endif
  52.  
  53. compile if not defined(CPP_EXTENSIONS)  -- Keep in sync with TAGS.E
  54.    CPP_EXTENSIONS = 'CPP HPP CXX HXX SQX JAV JAVA'
  55. compile endif
  56.  
  57. compile if INCLUDING_FILE <> 'EXTRA.E'  -- Following only gets defined in the base
  58. compile if EVERSION >= '4.12'
  59. ;  Keyset selection is now done once at file load time, not every time
  60. ;  the file is selected.  And because the DEFLOAD procedures don't have to be
  61. ;  kept together in the macros (ET will concatenate all the DEFLOADs the
  62. ;  same way it does DEFINITs), we can put the DEFLOAD here where it belongs,
  63. ;  with the rest of the keyset function.  (what a concept!)
  64. ;
  65. defload
  66.    universal load_ext
  67. compile if EPM
  68.    universal load_var
  69. compile endif
  70. compile if EVERSION >= '5.50'
  71.    if wordpos(load_ext, C_EXTENSIONS CPP_EXTENSIONS) then
  72. compile else
  73. ;                                               C++                                         Data Base Manager
  74.    if load_ext='C' or load_ext='H' or load_ext='CPP' or load_ext='HPP' or load_ext='CXX' or load_ext='SQC' then
  75. compile endif
  76.       keys   C_keys
  77.  compile if C_TABS <> 0
  78.   compile if EPM
  79.       if not (load_var // 2) then  -- 1 would be on if tabs set from EA EPM.TABS
  80.   compile endif
  81.       'tabs' C_TABS
  82.   compile if EPM
  83.       endif
  84.   compile endif
  85.  compile endif
  86.  compile if C_MARGINS <> 0
  87.   compile if EPM
  88.    compile if EVERSION >= '6.01b'
  89.       if not (load_var bitand 2) then  -- 2 would be on if tabs set from EA EPM.MARGINS
  90.    compile else
  91.       if not (load_var%2 - 2*(load_var%4)) then  -- 2 would be on if tabs set from EA EPM.MARGINS
  92.    compile endif
  93.   compile endif
  94.       'ma'   C_MARGINS
  95.   compile if EPM
  96.       endif
  97.   compile endif
  98.  compile endif
  99.  compile if (C_KEYWORD_HIGHLIGHTING | JAVA_KEYWORD_HIGHLIGHTING) and EPM32
  100.   compile if EVERSION >= '5.50' & INCLUDE_WORKFRAME_SUPPORT
  101.    compile if EVERSION >= '6.01b'
  102.     if not (.levelofattributesupport bitand 16) &
  103.    compile else
  104.     if not (.levelofattributesupport%16 - 2*(.levelofattributesupport%32)) &
  105.    compile endif
  106.        .visible then
  107.   compile else
  108.     if .visible then
  109.   compile endif
  110.        if substr(load_ext, 1, 3)='JAV' then
  111.   compile if JAVA_KEYWORD_HIGHLIGHTING and EPM32
  112.           'toggle_parse 1 epmkwds.jav'
  113.   compile endif
  114.        else
  115.   compile if C_KEYWORD_HIGHLIGHTING and EPM32
  116.           'toggle_parse 1 epmkwds.c'
  117.   compile endif
  118.        endif
  119.     endif
  120.  compile endif
  121.    endif
  122. compile endif
  123.  
  124. compile if WANT_CUA_MARKING & EPM
  125.  defkeys c_keys clear
  126. compile else
  127.  defkeys c_keys
  128. compile endif
  129.  
  130. compile if EVERSION >= 5
  131. def space=
  132. compile else
  133. def ' '=
  134. compile endif
  135.    universal expand_on
  136.    if expand_on then
  137.       if  not c_first_expansion() then
  138.          keyin ' '
  139.       endif
  140.    else
  141.       keyin ' '
  142.    endif
  143.  compile if EVERSION >= '5.20'
  144.    undoaction 1, junk                -- Create a new state
  145.  compile endif
  146.  
  147. compile if ASSIST_TRIGGER = 'ENTER'
  148. def enter=
  149.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  150.    universal enterkey
  151.  compile endif
  152. compile else
  153. def c_enter=
  154.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  155.    universal c_enterkey
  156.  compile endif
  157. compile endif
  158.    universal expand_on
  159.  
  160. compile if EVERSION >= 5
  161.    if expand_on then
  162. compile else
  163.    if expand_on & not command_state() then
  164. compile endif
  165. compile if EVERSION <= '4.12'
  166.       if c_second_expansion() then
  167.          call maybe_autosave()
  168.       else
  169. compile else
  170.       if not c_second_expansion() then
  171. compile endif
  172. compile if ASSIST_TRIGGER = 'ENTER'
  173.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  174.          call enter_common(enterkey)
  175.  compile else
  176.          call my_enter()
  177.  compile endif
  178. compile else  -- ASSIST_TRIGGER
  179.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  180.          call enter_common(c_enterkey)
  181.  compile else
  182.          call my_c_enter()
  183.  compile endif
  184. compile endif -- ASSIST_TRIGGER
  185.       endif
  186.    else
  187. compile if ASSIST_TRIGGER = 'ENTER'
  188.  compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  189.       call enter_common(enterkey)
  190.  compile else
  191.       call my_enter()
  192.  compile endif
  193. compile else  -- ASSIST_TRIGGER
  194.  compile if ENHANCED_ENTER_KEYS & c_ENTER_ACTION <> ''
  195.       call enter_common(c_enterkey)
  196.  compile else
  197.       call my_c_enter()
  198.  compile endif
  199. compile endif -- ASSIST_TRIGGER
  200.    endif
  201.  
  202. /* Taken out, interferes with some people's c_enter. */
  203. ;def c_enter=   /* I like Ctrl-Enter to finish the comment field also. */
  204. ;   getline line
  205. ;   if pos('/*',line) then
  206. ;      if not pos('*/',line) then
  207. ;         end_line;keyin' */'
  208. ;      endif
  209. ;   endif
  210. ;   down;begin_line
  211.  
  212. def c_x=       /* Force expansion if we don't have it turned on automatic */
  213.    if not c_first_expansion() then
  214.       call c_second_expansion()
  215.    endif
  216. compile endif  -- EXTRA
  217.  
  218. compile if not EXTRA_EX or INCLUDING_FILE = 'EXTRA.E'  -- Following gets defined in EXTRA.EX if it's being used
  219. define
  220.  compile if WANT_END_COMMENTED = '//'
  221.    END_CATCH  = ' // endcatch'
  222.    END_DO     = ' // enddo'
  223.    END_FOR    = ' // endfor'
  224.    END_IF     = ' // endif'
  225.    END_SWITCH = ' // endswitch'
  226.    END_TRY    = ' // endtry'
  227.    END_WHILE  = ' // endwhile'
  228.  compile elseif WANT_END_COMMENTED
  229.    END_CATCH  = ' /* endcatch */'
  230.    END_DO     = ' /* enddo */'
  231.    END_FOR    = ' /* endfor */'
  232.    END_IF     = ' /* endif */'
  233.    END_SWITCH = ' /* endswitch */'
  234.    END_TRY    = ' /* endtry */'
  235.    END_WHILE  = ' /* endwhile */'
  236.  compile else
  237.    END_CATCH  = ''
  238.    END_DO     = ''
  239.    END_FOR    = ''
  240.    END_IF     = ''
  241.    END_SWITCH = ''
  242.    END_TRY    = ''
  243.    END_WHILE  = ''
  244.  compile endif
  245.  
  246. defproc c_first_expansion
  247.    retc=1
  248. compile if EVERSION >= 5
  249.    if .line then
  250. compile else
  251.    if .line and (not command_state()) then
  252. compile endif
  253.       getline line
  254.       line=strip(line,'T')
  255.       w=line
  256.       wrd=upcase(w)
  257.       ws = substr(line, 1, max(verify(line, ' '\9)-1,0))
  258. compile if JAVA_SYNTAX_ASSIST
  259.       java = substr(filetype(), 1, 3) = 'JAV'
  260. compile endif -- JAVA_SYNTAX_ASSIST
  261. compile if CPP_SYNTAX_ASSIST
  262.  compile if EVERSION >= '5.50'
  263.       cpp = wordpos(filetype(), CPP_EXTENSIONS)
  264.  compile else
  265.       cpp = pos(' 'filetype()' ', ' 'CPP_EXTENSIONS' ')
  266.  compile endif
  267. compile endif -- CPP_SYNTAX_ASSIST
  268. compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  269.       ws2 = ws || substr('', 1, C_SYNTAX_INDENT)
  270. compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  271.       if wrd='FOR' then
  272. compile if WANT_BRACE_BELOW_STATEMENT
  273.          replaceline w' (; ; )'
  274.  compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  275.          insertline ws2'{', .line+1
  276.          insertline ws2'}'END_FOR, .line+2
  277.  compile else
  278.          insertline ws'{', .line+1
  279.          insertline ws'}'END_FOR, .line+2
  280.  compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  281. compile else
  282.          replaceline w' (; ; ) {'
  283.          insertline ws'}'END_FOR, .line+1
  284. compile endif -- WANT_BRACE_BELOW_STATEMENT
  285.          if not insert_state() then insert_toggle
  286. compile if EVERSION >= '5.50'
  287.              call fixup_cursor()
  288. compile endif
  289.          endif
  290.          .col=.col+2
  291.       elseif wrd='IF' then
  292. compile if WANT_BRACE_BELOW_STATEMENT
  293.          replaceline w' ()'
  294.  compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  295.          insertline ws2'{', .line+1
  296.          insertline ws2'}', .line+2
  297.  compile else
  298.          insertline ws'{', .line+1
  299.          insertline ws'}', .line+2
  300.  compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  301.          insertline ws'else', .line+3
  302.  compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  303.          insertline ws2'{', .line+4
  304.          insertline ws2'}'END_IF, .line+5
  305.  compile else
  306.          insertline ws'{', .line+4
  307.          insertline ws'}'END_IF, .line+5
  308.  compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  309. compile else
  310.          replaceline w' () {'
  311.          insertline ws'} else {', .line+1
  312.          insertline ws'}'END_IF, .line+2
  313. compile endif -- WANT_BRACE_BELOW_STATEMENT
  314.          if not insert_state() then insert_toggle
  315. compile if EVERSION >= '5.50'
  316.          call fixup_cursor()
  317. compile endif
  318.          endif
  319.          .col=.col+2
  320.       elseif wrd='WHILE' then
  321. compile if WANT_BRACE_BELOW_STATEMENT
  322.          replaceline w' ()'
  323.  compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  324.          insertline ws2'{', .line+1
  325.          insertline ws2'}'END_WHILE, .line+2
  326.  compile else
  327.          insertline ws'{', .line+1
  328.          insertline ws'}'END_WHILE, .line+2
  329.  compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  330. compile else
  331.          replaceline w' () {'
  332.          insertline ws'}'END_WHILE, .line+1
  333. compile endif -- WANT_BRACE_BELOW_STATEMENT
  334.          if not insert_state() then insert_toggle
  335. compile if EVERSION >= '5.50'
  336.              call fixup_cursor()
  337. compile endif
  338.          endif
  339.          .col=.col+2
  340.       elseif wrd='DO' then
  341. compile if WANT_BRACE_BELOW_STATEMENT
  342.  compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  343.          insertline ws2'{', .line+1
  344.          insertline ws2'} while (  );'END_DO, .line+2
  345.  compile else
  346.          insertline ws'{', .line+1
  347.          insertline ws'} while (  );'END_DO, .line+2
  348.  compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  349.          down
  350. compile else
  351.          replaceline w' {'
  352.          insertline ws'} while (  );'END_DO, .line+1
  353. compile endif -- WANT_BRACE_BELOW_STATEMENT
  354.          call einsert_line()
  355.          .col=.col+C_SYNTAX_INDENT    /* indent for new line */
  356.       elseif wrd='SWITCH' then
  357. compile if WANT_BRACE_BELOW_STATEMENT
  358.          replaceline w' ()'
  359.  compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  360.          insertline ws2'{', .line+1
  361.          insertline ws2'}'END_SWITCH, .line+2
  362.  compile else
  363.          insertline ws'{', .line+1
  364.          insertline ws'}'END_SWITCH, .line+2
  365.  compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  366. compile else
  367.          replaceline w' () {'
  368.          insertline ws'}'END_SWITCH, .line+1
  369. compile endif -- WANT_BRACE_BELOW_STATEMENT
  370.          if not insert_state() then insert_toggle
  371. compile if EVERSION >= '5.50'
  372.              call fixup_cursor()
  373. compile endif
  374.          endif
  375.          .col=.col+2    /* move cursor between parentheses of switch ()*/
  376.       elseif wrd='MAIN' then
  377.          call enter_main_heading()
  378. compile if CPP_SYNTAX_ASSIST
  379.       elseif wrd='TRY' & cpp then
  380.  compile if WANT_BRACE_BELOW_STATEMENT
  381.   compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  382.          insertline ws2'{', .line+1
  383.          insertline ws2'}'END_TRY, .line+2
  384.   compile else
  385.          insertline ws'{', .line+1
  386.          insertline ws'}'END_TRY, .line+2
  387.   compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  388.          insertline ws'catch (  )', .line+3
  389.   compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  390.          insertline ws2'{', .line+4
  391.          insertline ws2'}'END_CATCH, .line+5
  392.   compile else
  393.          insertline ws'{', .line+4
  394.          insertline ws'}'END_CATCH, .line+5
  395.   compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  396.          down
  397.  compile else
  398.          replaceline w' {'
  399.          insertline ws'}'END_TRY, .line+1
  400.          insertline ws'catch (  ) {', .line+2
  401.          insertline ws'}'END_CATCH, .line+3
  402.  compile endif -- WANT_BRACE_BELOW_STATEMENT
  403.       elseif cpp & wrd='CATCH' then
  404.  compile if WANT_BRACE_BELOW_STATEMENT
  405.          replaceline w' (  )'
  406.   compile if WANT_BRACE_BELOW_STATEMENT_INDENTED
  407.          insertline ws2'{', .line+1
  408.          insertline ws2'}'END_CATCH, .line+2
  409.   compile else
  410.          insertline ws'{', .line+1
  411.          insertline ws'}'END_CATCH, .line+2
  412.   compile endif -- WANT_BRACE_BELOW_STATEMENT_INDENTED
  413.  compile else
  414.          replaceline w' (  ) {'
  415.          insertline ws'}'END_CATCH, .line+1
  416.  compile endif -- WANT_BRACE_BELOW_STATEMENT
  417.          if not insert_state() then insert_toggle
  418.  compile if EVERSION >= '5.50'
  419.              call fixup_cursor()
  420.  compile endif
  421.          endif
  422.          .col=.col+3
  423. compile endif -- CPP_SYNTAX_ASSIST
  424. compile if JAVA_SYNTAX_ASSIST
  425.       elseif wrd='PRINTLN(' & java then
  426.          replaceline ws'System.out.println( );'
  427.          if not insert_state() then insert_toggle
  428.  compile if EVERSION >= '5.50'
  429.              call fixup_cursor()
  430.  compile endif
  431.          endif
  432.          tab_word
  433. compile endif -- JAVA_SYNTAX_ASSIST
  434.       else
  435.          retc=0
  436.       endif
  437.    else
  438.       retc=0
  439.    endif
  440.    return retc
  441.  
  442. defproc c_second_expansion
  443.    retc=1
  444.    if .line then
  445.       getline line
  446.       parse value upcase(line) with '{' +0 a
  447.       brace = pos('{', line)
  448.       if .line < .last then
  449.          next_is_brace = textline(.line+1)='{'
  450.       else
  451.          next_is_brace = 0
  452.       endif
  453.       parse value line with wrd rest
  454.       i=verify(wrd,'({:;','M',1)-1
  455.       if i<=0 then i=length(wrd) endif
  456.       firstword=upcase(substr(wrd,1,i))
  457. compile if CPP_SYNTAX_ASSIST
  458.  compile if EVERSION >= '5.50'
  459.       cpp = wordpos(filetype(), CPP_EXTENSIONS)
  460.  compile else
  461.       cpp = pos(' 'filetype()' ', ' 'CPP_EXTENSIONS' ')
  462.  compile endif
  463. compile endif -- CPP_SYNTAX_ASSIST
  464.       if firstword='FOR' then
  465.          /* do tabs to fields of C for statement */
  466.          cp=pos(';',line,.col)
  467.          if cp and cp>=.col then
  468.              .col=cp+2
  469.          else
  470.            cpn=pos(';',line,cp+1)
  471.            if cpn and (cpn>=.col) then
  472.              .col=cpn+2
  473.            else
  474.               if not brace and next_is_brace then down; endif
  475.              call einsert_line()
  476.              .col=.col+C_SYNTAX_INDENT
  477.            endif
  478.          endif
  479.       elseif firstword='CASE' or firstword='DEFAULT' then
  480.          call einsert_line()
  481.          if .line>2 then  /* take a look at the previous line */
  482.             getline prevline, .line-2
  483.             prevline=upcase(prevline)
  484.             parse value prevline with w .
  485.             if pos('(', w) then
  486.                parse value w with w '('
  487.             endif
  488.             if w='CASE' then  /* align case statements */
  489.                i=pos('C',prevline)
  490.                replaceline substr('',1,i-1)||wrd rest, .line-1
  491.                .col=i
  492.             elseif w<>'CASE' and w<>'SWITCH' and w<>'{' and prevline<>'' then  /* shift current line over */
  493.                i=verify(prevline,' ')
  494.                if i then .col=i endif
  495.                if i>C_SYNTAX_INDENT then i=i-C_SYNTAX_INDENT else i=1 endif
  496.                .col=i
  497.                replaceline substr('',1,i-1)||wrd rest, .line-1
  498.             endif
  499.             /* get rid of line containing just a ; */
  500.             if firstword='DEFAULT' and .line <.last then
  501.                getline line, .line+1
  502.                if line=';' then
  503.                   deleteline .line+1
  504.                endif
  505.             endif
  506.          endif
  507.          .col=.col+C_SYNTAX_INDENT
  508.       elseif firstword='BREAK' then
  509.          call einsert_line()
  510.          c=.col
  511.          if .col>C_SYNTAX_INDENT then
  512.             .col=.col-C_SYNTAX_INDENT
  513.          endif
  514.          keyin 'case :';left
  515.          insertline substr('',1,c-1)'break;', .line+1
  516.       elseif firstword='SWITCH' then
  517.          if not brace and next_is_brace then down; endif
  518.          call einsert_line()
  519.          c=.col
  520. compile if I_like_my_cases_under_my_switch
  521.          keyin 'case :';left
  522. compile else
  523.          keyin substr(' ',1,C_SYNTAX_INDENT)'case :';left
  524.          c=c+C_SYNTAX_INDENT
  525. compile endif
  526.          insertline substr(' ',1,c+C_SYNTAX_INDENT-1)'break;', .line+1
  527.          /* look at the next line to see if this is the first time */
  528.          /* the user typed enter on this switch statement */
  529.          if .line<=.last-2 then
  530.             getline line, .line+2
  531.             i=verify(line,' ')
  532.             if i then
  533.                if substr(line,i,1)='}' then
  534. compile if I_like_my_cases_under_my_switch
  535.                   if i>1 then
  536.                      i=i-1
  537.                      insertline substr(' ',1,i)'default:', .line+2
  538.                   else
  539.                      insertline 'default:', .line+2
  540.                   endif
  541. compile else
  542.                   i=i+C_SYNTAX_INDENT-1
  543.                   insertline substr(' ',1,i)'default:', .line+2
  544. compile endif
  545. compile if ADD_BREAK_AFTER_DEFAULT
  546.                   insertline substr(' ',1,i+C_SYNTAX_INDENT-1)'break;', .line+3
  547. compile elseif I_like_a_semicolon_supplied_after_default then
  548.                   insertline substr(' ',1,i+C_SYNTAX_INDENT)';', .line+3
  549. compile endif
  550.                endif
  551.             endif
  552.          endif
  553. compile if CPP_SYNTAX_ASSIST
  554.       elseif cpp & firstword='CATCH' then
  555.          cp=pos('(  )', line, .col)
  556.          if cp then
  557.             .col=cp+2
  558.             if not insert_state() then insert_toggle
  559.  compile if EVERSION >= '5.50'
  560.                 call fixup_cursor()
  561.  compile endif
  562.             endif
  563.          else
  564.             if not brace and next_is_brace then down; endif
  565.             call einsert_line()
  566.             .col=.col+C_SYNTAX_INDENT
  567.          endif
  568. compile endif -- CPP_SYNTAX_ASSIST
  569.       elseif a='{' or firstword='{' then  /* firstword or last word {?*/
  570. ;        if firstword='{' then
  571. ;           replaceline  wrd rest      -- This shifts the { to col 1.  Why???
  572. ;           call einsert_line();.col=C_SYNTAX_INDENT+1
  573. ;        else
  574.             call einsert_line()
  575.             .col=.col+C_SYNTAX_INDENT
  576. ;        endif
  577.       elseif firstword='MAIN' then
  578.          call enter_main_heading()
  579. compile if EPM
  580.  compile if CPP_SYNTAX_ASSIST
  581.       elseif (wordpos(firstword, 'DO IF ELSE WHILE') |
  582.               (cpp & wordpos(firstword, 'TRY'))) then
  583.  compile else
  584.       elseif wordpos(firstword, 'DO IF ELSE WHILE') then
  585.  compile endif -- CPP_SYNTAX_ASSIST
  586. compile else
  587.  compile if CPP_SYNTAX_ASSIST
  588.       elseif pos(' 'firstword' ', ' DO IF ELSE WHILE ') | (cpp & firstword='TRY') then
  589.  compile else
  590.       elseif pos(' 'firstword' ', ' DO IF ELSE WHILE ') then
  591.  compile endif -- CPP_SYNTAX_ASSIST
  592. compile endif
  593.          if not brace and next_is_brace then down; endif
  594.          call einsert_line()
  595.          .col=.col+C_SYNTAX_INDENT
  596. ;        insert
  597. ;        .col=length(a)+2
  598. compile if TERMINATE_COMMENTS
  599.       elseif pos('/*',line) then
  600.          if not pos('*/',line) then
  601.             end_line;keyin' */'
  602.          endif
  603.          call einsert_line()
  604. compile endif
  605.       else
  606.          retc=0
  607.       endif
  608.    else
  609.       retc=0
  610.    endif
  611.    return retc
  612.  
  613. defproc enter_main_heading
  614. compile if not USE_ANSI_C_NOTATION     -- Use standard notation
  615.    temp=substr('',1,C_SYNTAX_INDENT)  /* indent spaces */
  616.    replaceline 'main(argc, argv, envp)'
  617.    insertline temp'int argc;', .line+1         /* double indent */
  618.    insertline temp'char *argv[];', .line+2
  619.    insertline temp'char *envp[];', .line+3
  620.    insertline '{', .line+4
  621.    insertline '', .line+5
  622.    mainline = .line
  623.    if .cursory<7 then
  624.       .cursory=7
  625.    endif
  626.    mainline+5
  627.    .col=C_SYNTAX_INDENT+1
  628.    insertline '}', .line+1
  629. compile else                           -- Use shorter ANSII notation
  630.    replaceline 'main(int argc, char *argv[], char *envp[])'
  631.    insertline '{', .line+1
  632.    insertline '', .line+2
  633.    .col=C_SYNTAX_INDENT+1
  634.    insertline '}', .line+3
  635.    mainline = .line
  636.    if .cursory<4 then
  637.       .cursory=4
  638.    endif
  639.    mainline+2
  640. compile endif
  641.  
  642. compile endif  -- EXTRA
  643.