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