home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmkmap1.zip / STDKEYS.ORG < prev   
Text File  |  1994-07-19  |  63KB  |  2,153 lines

  1. define
  2. compile if EVERSION < 5
  3.    NOT_CMD_STATE = '& not command_state()'
  4. compile else
  5.    NOT_CMD_STATE = ' '
  6. compile endif
  7.  
  8. definit
  9.    universal blockreflowflag
  10. compile if defined(HIGHLIGHT_COLOR)
  11.    universal search_len
  12. compile endif
  13. compile if EVERSION < 5
  14.    universal inKstring
  15.    inKstring=0
  16. compile endif
  17.    blockreflowflag=0
  18. compile if defined(HIGHLIGHT_COLOR)
  19.    search_len = 5     -- Initialize to anything, to prevent possible "Invalid number argument"
  20. compile endif
  21.  
  22. compile if WANT_CUA_MARKING & EPM
  23. defkeys edit_keys new clear
  24.  
  25. def otherkeys =
  26.    k = lastkey()
  27.    call process_key(k)
  28.  
  29. defproc process_key(k)
  30.  compile if WANT_CUA_MARKING = 'SWITCH'
  31.    universal CUA_marking_switch
  32.  compile endif
  33.    if length(k)=1 & k<>\0 then
  34.       i_s = insert_state()
  35.  compile if WANT_CUA_MARKING = 'SWITCH'
  36.       if CUA_marking_switch then
  37.  compile endif
  38.          had_mark = process_mark_like_cua()
  39.          if not i_s & had_mark then
  40.             insert_toggle  -- Turn on insert mode because the key should replace
  41.          endif             -- the mark, not the character after the mark.
  42.  compile if WANT_CUA_MARKING = 'SWITCH'
  43.       else
  44.          had_mark = 0  -- set to 0 so we don't toggle insert state later
  45.       endif
  46.  compile endif
  47.       keyin k
  48.       if not i_s & had_mark then
  49.          insert_toggle
  50.       endif
  51.    endif
  52.  
  53. defproc process_mark_like_cua()
  54.    if marktype() then
  55.       getmark firstline,lastline,firstcol,lastcol,markfileid
  56.       getfileid fileid
  57.       if fileid<>markfileid then
  58.          sayerror MARKED_OTHER__MSG
  59.          unmark
  60.       elseif not check_mark_on_screen() then
  61.          sayerror MARKED_OFFSCREEN__MSG
  62.          unmark
  63.       else
  64. compile if WANT_DM_BUFFER
  65.          'Copy2DMBuff'     -- see clipbrd.e for details
  66. compile endif  -- WANT_DM_BUFFER
  67.          firstline; .col=firstcol
  68. compile if EVERSION >= '5.20'
  69.          undoaction 1, junk                -- Create a new state
  70. compile endif
  71.          call pdelete_mark()
  72.          'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  73.          return 1
  74.       endif
  75.    endif
  76.  
  77. defproc shifted
  78.    ks = getkeystate(VK_SHIFT)
  79.    return ks<>3 & ks<>4
  80.  
  81. compile if EVERSION < 5.50
  82. define CHARG_MARK = 'CHAR'
  83. compile else                -- New mark type
  84. define CHARG_MARK = 'CHARG'
  85. compile endif
  86.  
  87. defproc extend_mark(startline, startcol, forward)
  88. ;compile if WANT_CUA_MARKING = 'SWITCH'
  89. ;  universal CUA_marking_switch
  90. ;  if not CUA_marking_switch then return; endif
  91. ;compile endif
  92.    if marktype()='LINE' | marktype()='BLOCK' then return; endif
  93.    getfileid curfileid
  94.    if not marktype() then
  95. compile if EVERSION < 5.50  -- Forwards and backwards acts differently
  96.       call pset_mark(startline, .line, startcol-(not forward), .col-forward, CHARG_MARK, curfileid)
  97. compile else  -- CHARG handles the differences.
  98.       call pset_mark(startline, .line, startcol, .col, CHARG_MARK, curfileid)
  99. compile endif
  100.       return
  101.    endif
  102. compile if EVERSION < 5.50
  103.    getmark firstline,lastline,firstcol,lastcol,markfileid
  104. compile else
  105.    getmarkg firstline,lastline,firstcol,lastcol,markfileid
  106. compile endif
  107.    if markfileid<>curfileid then  -- If mark was in a different file, treat like no mark was set.
  108. compile if EVERSION < 5.50  -- Forwards and backwards acts differently
  109.       call pset_mark(startline, .line, startcol-(not forward), .col-forward, CHARG_MARK, curfileid)
  110. compile else  -- CHARG handles the differences.
  111.       call pset_mark(startline, .line, startcol, .col, CHARG_MARK, curfileid)
  112. compile endif
  113.       return
  114.    endif
  115.    lk = lastkey(0)
  116.    if (lk=s_up & .line=firstline-1) | (lk=s_down & .line=firstline+1) then
  117.       if length(textline(firstline)) < .col then
  118.          firstcol = .col
  119.       endif
  120.    endif
  121.    if startline>firstline | ((startline=firstline) & (startcol > firstcol)) then  -- at end of mark
  122.       if not forward then
  123.          if firstline=.line & firstcol=.col then unmark; return; endif
  124.       endif
  125. compile if EVERSION < '5.50'
  126.       call pset_mark(firstline, .line, firstcol, .col-1, CHARG_MARK, curfileid)
  127. compile else
  128.       call pset_mark(firstline, .line, firstcol, .col, CHARG_MARK, curfileid)
  129. compile endif
  130.    else                                                         -- at beginning of mark
  131.       if forward then
  132.          if lastline=.line & lastcol=.col-1 then unmark; return; endif
  133.       endif
  134.       call pset_mark(lastline, .line, lastcol, .col, CHARG_MARK, curfileid)
  135.    endif
  136.  
  137. ; c_home, c_end, c_left & c_right do different things if the shift key is depressed.
  138. ; The logic is extracted here mainly due to the complexity of the COMPILE IF's
  139. defproc begin_shift(var startline, var startcol, var shift_flag)
  140.  compile if WANT_CUA_MARKING = 'SWITCH'
  141.    universal CUA_marking_switch
  142.  compile endif
  143.    shift_flag = shifted()
  144.  compile if WANT_CUA_MARKING = 'SWITCH'
  145.    if shift_flag or not CUA_marking_switch then
  146.  compile else
  147.    if shift_flag then
  148.  compile endif
  149.       startline = .line; startcol = .col
  150.    else
  151.       unmark
  152.    endif
  153.  
  154. defproc end_shift(startline, startcol, shift_flag, forward_flag)
  155.  compile if WANT_CUA_MARKING = 'SWITCH'
  156.    universal CUA_marking_switch
  157.    if shift_flag & CUA_marking_switch then
  158.  compile else
  159.    if shift_flag then
  160.  compile endif
  161.       call extend_mark(startline, startcol, forward_flag)
  162.    endif
  163. compile else  -- WANT_CUA_MARKING & EPM
  164. defkeys edit_keys new
  165. compile endif  -- WANT_CUA_MARKING & EPM
  166.  
  167. compile if EVERSION < 5
  168. def entry=
  169. compile endif
  170.  
  171. ; Real keys, in alphabetical order.
  172. ; See end of this file for a list of keys unused in standard E.
  173.  
  174. def a_0=    /* same as Alt-Equal, for sake of German keyboards */
  175.    'dolines'
  176.  
  177. ; We now distribute a standard front end for the DIR command, which redirects
  178. ; the output to a file named ".dos dir <dirspec>".  The third line should be
  179. ; "Directory of <dirname>".  If so, we use it.  If not, we use DIRSPEC from the
  180. ; .filename instead, but note that the latter might contain wildcards.
  181. define
  182.    QUOTED_DIR_STRING ='"'DIRECTORYOF_STRING'"'
  183.  
  184. def a_1= /* edit filename on current text line */
  185.    getline line
  186. compile if (EVERSION >= '4.12' & EVERSION < 5 & SHELL_USAGE) | WANT_EPM_SHELL
  187.  compile if EOS2
  188.    if .filename = '.SHELL' then
  189.  compile else
  190.    if leftstr(.filename, 15) = ".command_shell_" then
  191.  compile endif
  192.       if substr(line, 13, 1) = ' ' then  -- old format DIR, or not a DIR line
  193.          flag = substr(line, 1, 1) <> ' ' &
  194.                 (isnum(substr(line, 14, 8)) | substr(line, 14, 8)='<DIR>') &
  195.                 length(line) < 40 &
  196.                 isnum(substr(line, 24, 2) || substr(line, 27, 2) || substr(line, 30, 2)) &
  197.                 substr(line, 26, 1) = substr(line, 29, 1) &
  198.                 pos(substr(line, 26, 1), '/x.-')
  199.          filename=strip(substr(line,1,8))
  200.          word2=strip(substr(line,10,3))
  201.          if word2<>'' then filename=filename'.'word2; endif
  202.       else                               -- new format DIR, or not a DIR line
  203.          flag = substr(line, 41, 1) <> ' ' &
  204.                 (isnum(substr(line, 18, 9)) | substr(line, 18, 9)='<DIR>') &
  205.                 isnum(substr(line, 1, 2) || substr(line, 4, 2) || substr(line, 7, 2)) &
  206.                 substr(line, 3, 1) = substr(line, 6, 1) &
  207.                 pos(substr(line, 3, 1), '/x.-')
  208.          filename=substr(line,41)
  209.       endif
  210.       if flag then
  211.          call psave_pos(save_pos)
  212.          getsearch oldsearch
  213.  compile if EPM
  214.          display -2
  215.  compile endif
  216.          'xcom l /'DIRECTORYOF_STRING'/c-'
  217.          dir_rc = rc
  218.          if not rc then
  219.             getline word3
  220.             parse value word3 with $QUOTED_DIR_STRING word3
  221. ;;          parse value word3 with . . word3 .
  222.             if verify(word3,'?*','M') then  -- If wildcards - must be 4OS2 or similar shell
  223.                word3 = substr(word3, 1, lastpos(word3, '\')-1)
  224.             endif
  225.             word3 = strip(word3)
  226.  compile if EOS2
  227.          else
  228.             sayerror 1
  229.  compile endif
  230.          endif
  231.  compile if EPM
  232.          display 2
  233.  compile endif
  234.          setsearch oldsearch
  235.          call prestore_pos(save_pos)
  236.          if not dir_rc then
  237.             name=word3 ||                            -- Start with the path.
  238.                  leftstr('\',                        -- Append a '\', but only if path
  239.                          '\'<>rightstr(word3,1)) ||  -- doesn't end with one.
  240.                  filename                            -- Finally, the filename
  241.  compile if not E3  -- DOS (box) doesn't see new-format filenames
  242.             if pos(' ',name) then  -- enquote
  243.                name = '"'name'"'
  244.             endif
  245.  compile endif
  246.             if pos('<DIR>',line) then
  247.                'dir 'name
  248.             else
  249.                'e 'name
  250.             endif
  251.             return
  252.          endif
  253.       endif
  254.    endif
  255. compile endif  -- SHELL_USAGE | WANT_EPM_SHELL
  256.    parse value .filename with word1 word2 word3 .
  257.    if upcase(word1 word2) = '.DOS DIR' then
  258.       call psave_pos(save_pos)
  259. compile if EVERSION >= '4.12'
  260.       getsearch oldsearch
  261. compile endif
  262.       'xcom l /'DIRECTORYOF_STRING'/c-'
  263.       if not rc then
  264.          getline word3
  265.          parse value word3 with $QUOTED_DIR_STRING word3
  266. ;        parse value word3 with . . word3 .
  267.          if verify(word3,'?*','M') then  -- If wildcards - must be 4OS2 or similar shell
  268.             word3 = substr(word3, 1, lastpos(word3, '\')-1)
  269.          endif
  270.          word3 = strip(word3)
  271.       endif
  272. compile if EVERSION >= '4.12'
  273.       setsearch oldsearch
  274. compile endif
  275.       call prestore_pos(save_pos)
  276. compile if not E3  -- DOS (box) doesn't see new-format DIR listing
  277.       filename=substr(line,41)                 -- Support HPFS.  FAT dir's end at 40
  278.       if filename='' then                      -- Must be FAT.
  279. compile endif
  280.          filename=strip(substr(line,1,8))
  281.          word2=strip(substr(line,10,3))
  282.          if word2<>'' then filename=filename'.'word2; endif
  283. compile if not E3  -- DOS (box) doesn't see new-format DIR listing
  284.       endif
  285. compile endif
  286.       name=word3 ||                            -- Start with the path.
  287. compile if EVERSION >= '5.17'
  288.            leftstr('\',                        -- Append a '\', but only if path
  289.                    '\'<>rightstr(word3,1)) ||  -- doesn't end with one.
  290. compile else
  291.            substr('\', 1,                      -- Append a '\', but only if path
  292.                   '\'<>substr(word3,length(word3),1)) ||  -- doesn't end with one.
  293. compile endif
  294.            filename                            -- Finally, the filename
  295. compile if not E3  -- DOS (box) doesn't see new-format filenames
  296.       if pos(' ',name) then  -- enquote
  297.          name = '"'name'"'
  298.       endif
  299. compile endif
  300.       if pos('<DIR>',line) then
  301.          'dir 'name
  302.       else
  303.          'e 'name
  304.       endif
  305. compile if WANT_TREE
  306.    elseif .filename = '.tree' then
  307.       if substr(line,5,1)substr(line,8,1)substr(line,15,1)substr(line,18,1) = '--::' then
  308.          name = substr(line, 52)
  309.          if substr(line,31,1)='>' then
  310. ;           if isadefc('tree_dir') then
  311.                'tree_dir' name'\*.*'
  312. ;           else
  313. ;              'dir' name
  314. ;           endif
  315.          else
  316.             'e' name
  317.          endif
  318.       endif
  319. compile endif  -- WANT_TREE
  320.    else  -- Not a DIR listing
  321. compile if not E3
  322.       parse value line with w1 rest
  323.       p=lastpos('(', w1)
  324.       if p then
  325.          filename = substr(w1, 1, p-1)
  326.          parse value substr(w1, p+1) with line ')'
  327.          parse value line with line ':' col
  328.          if pos('*', filename) then
  329.             if YES_CHAR<>askyesno(WILDCARD_WARNING__MSG, '', filename) then
  330.                return
  331.             endif
  332.          endif
  333.          'e 'filename
  334.          line
  335.          if col<>'' then .col = col; endif
  336.       else
  337.          if pos('*', line) then
  338.             if YES_CHAR<>askyesno(WILDCARD_WARNING__MSG, '', line) then
  339.                return
  340.             endif
  341.          endif
  342. compile endif
  343.          'e 'line
  344. compile if not E3
  345.       endif
  346. compile endif
  347.    endif
  348.  
  349. compile if WANT_WINDOWS
  350. def a_4=call psplit4()            -- routine defined in WINDOW.E
  351. compile endif
  352.  
  353. def a_a=
  354. compile if WANT_CHAR_OPS
  355.    call pcommon_adjust_overlay('A')
  356. compile else
  357.    adjustblock
  358. compile endif
  359.  
  360. def a_b
  361.    markblock
  362. compile if EVERSION >= 5
  363.    'Copy2SharBuff'       /* Copy mark to shared text buffer */
  364. compile endif
  365.  
  366. def a_c=
  367. compile if EPM
  368.    if marktype() then
  369. compile endif
  370.       call pcopy_mark()
  371. compile if EPM
  372.    else                 /* If no mark, look to in Shared Text buffer */
  373.       'GetSharBuff'     /* see clipbrd.e for details                 */
  374.    endif
  375. compile endif
  376.  
  377. def a_d=
  378. compile if WANT_DM_BUFFER
  379.    'Copy2DMBuff'     -- see clipbrd.e for details
  380. compile endif
  381.    call pdelete_mark()
  382. compile if EVERSION > 5
  383.    'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  384. compile endif
  385.  
  386. def a_e=
  387.    call pend_mark()
  388.    if substr(marktype(),1,1)<>'L' then
  389.       right
  390.    endif
  391.  
  392. def a_equal=
  393.    'dolines'   -- Code is a separate command in STDCMDS.E.
  394.  
  395. def a_f= /* Now accepts key from macro. */
  396.    call checkmark()
  397. compile if EVERSION < 5
  398.    k=mgetkey("Type a character, or Esc to cancel.")
  399.    if length(k)>1 then           -- Do something with extended keys.
  400.       if     k=esc      then ;   -- Let user abort w/o Ctrl-break.
  401.       elseif k=padstar  then k='*'
  402.       elseif k=padplus  then k='+'
  403.       elseif k=padminus then k='-'
  404.       else   k=substr(k,2,1)      endif
  405.    endif
  406.    if k<>esc then call pfill_mark(k); endif
  407. compile else
  408.    call pfill_mark()
  409. compile endif
  410.  
  411. def a_f1= keyin '║ ╠ ╔ ╚ ╩ ═ ╦ ╝ ╗ ╣ ╬ │ ├ ┌ └ ┴ ─ ┬ ┘ ┐ ┤ ┼ █ ▓ ▒ ░'
  412.  
  413. def a_f7,c_F7=   -- Can't use the old A_F7 in EPM.  PM uses it as an accelerator key.
  414.    shift_left
  415. compile if SHIFT_BLOCK_ONLY
  416.    if marktype()='BLOCK' then  -- code by Bob Langer
  417.       getmark fl,ll,fc,lc,fid
  418.       call pset_mark(fl,ll,lc,MAXCOL,'BLOCK',fid)
  419.       shift_right
  420.       call pset_mark(fl,ll,fc,lc,'BLOCK',fid)
  421.    endif
  422. compile endif
  423.  
  424. def a_f8,c_F8=   -- Can't use the old A_F8 in EPM.  PM uses it as an accelerator key.
  425. compile if SHIFT_BLOCK_ONLY
  426.    if marktype()='BLOCK' then  -- code by Bob Langer
  427.       getmark fl,ll,fc,lc,fid
  428.       call pset_mark(fl,ll,lc,MAXCOL,'BLOCK',fid)
  429.       shift_left
  430.       call pset_mark(fl,ll,fc,lc,'BLOCK',fid)
  431.    endif
  432. compile endif
  433.    shift_right
  434.  
  435. compile if EVERSION < 5
  436.  compile if EVERSION < '4.10'          -- Early E doesn't support enh. kbd.
  437. def a_f10,c_P= call pprevfile()       -- routine defined in WINDOW.E
  438.  compile else
  439. def a_f10,F11,c_P= call pprevfile()       -- routine defined in WINDOW.E
  440.  compile endif
  441. compile else
  442. /* We can't use a_f10 for previous file any more, PM uses that key. */
  443. /* I like F11 and F12 to go back and forth.                         */
  444. def a_f10,F11,c_P=  -- a_F10 is usual E default; F11 for enh. kbd, c_P for EPM.
  445.    prevfile
  446. compile endif
  447.  
  448. def a_j=
  449.    call joinlines()
  450.  
  451. def a_l=
  452.    mark_line
  453. compile if EVERSION >= 5
  454.    'Copy2SharBuff'       /* Copy mark to shared text buffer */
  455. compile endif
  456.  
  457. def a_m=call pmove_mark()
  458. compile if UNMARK_AFTER_MOVE
  459.    unmark
  460.  compile if EVERSION > 5
  461.    'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  462.  compile endif
  463. compile endif
  464.  
  465. def a_minus =
  466.  compile if EOS2
  467.    display 0
  468.  compile endif
  469.  compile if EVERSION < '5.50'
  470.    sayat '', .cursory, .cursorx, WHITE + REDB + BLINK, 1
  471.  compile elseif EVERSION >= '5.60'
  472.    circleit 5, .line, .col-1, .col+1, 16777220
  473.  compile else
  474.    circleit 2, .line, .col-1, .col+1, WHITE + REDB + BLINK
  475.  compile endif
  476.  compile if EPM & EVERSION < '5.50'
  477.    call dynalink('DOSCALLS', '#32', atol_swap(1000))  -- 1 second DOSSLEEP
  478.    refresh
  479.  compile endif
  480.  compile if EOS2
  481.    k=getkey()
  482.    display 1
  483.    executekey k
  484.  compile endif
  485.  
  486. def a_n=  /* Type the full name of the current file. */
  487.   keyin .filename
  488.  
  489. def a_o=
  490. compile if EPM
  491.    if marktype() then
  492. compile endif
  493. compile if WANT_CHAR_OPS
  494.       call pcommon_adjust_overlay('O')
  495. compile else
  496.       overlay_block
  497. compile endif
  498. compile if EPM
  499.    else                 /* If no mark, look to in Shared Text buffer */
  500.       'GetSharBuff O'   /* see clipbrd.e for details                 */
  501.    endif
  502. compile endif
  503.  
  504. def a_p=
  505.    /* Protect the user from accidentally reflowing a marked  */
  506.    /* area not in the current file, and give a good message. */
  507.    mt = substr(marktype(), 1, 1)
  508.    if mt='B' or mt='L' then
  509.       getmark firstline,lastline,firstcol,lastcol,markfileid
  510.       getfileid fileid
  511.       if fileid<>markfileid then
  512.          sayerror CANT_REFLOW__MSG'  'OTHER_FILE_MARKED__MSG
  513.          return
  514.       endif
  515.    endif
  516.  
  517.    if mt<>' ' then
  518.       if not check_mark_on_screen() then
  519. compile if EVERSION < 5
  520.          do while testkey()/==''; call getkey(); end
  521.          sayerror MARK_OFF_SCRN_YN__MSG
  522.          loop
  523.             ch=upcase(getkey())
  524.             if ch=YES_CHAR then sayerror 0; leave; endif
  525.             if ch=NO_CHAR or ch=esc then sayerror 0; stop; endif
  526.          endloop
  527. compile else
  528.          sayerror MARK_OFF_SCREEN__MSG
  529.          stop
  530. compile endif
  531.       endif
  532.    endif
  533.  
  534.    if mt='B' then
  535.       'box r'
  536.    elseif mt='C' then
  537.       sayerror WRONG_MARK__MSG
  538.    elseif mt='L' then
  539.       reflow
  540.    else  -- Standard text reflow split into a separate routine.
  541.       call text_reflow()
  542.    endif
  543.  
  544. definit                         -- Variable is null if alt_R is not active.
  545.    universal alt_R_active       -- For E3/EOS2, it's 1 if alt_R is active.
  546.    alt_R_active = ''            -- For EPM, it's set to querycontrol(messageline).
  547.  
  548. def a_r=
  549.    universal alt_R_active,tempofid
  550. compile if EPM
  551.    universal alt_R_space
  552. compile endif
  553.  
  554.    if alt_R_active<>'' then
  555. compile if EPM
  556.       call pblock_reflow(1,alt_R_space,tempofid)     -- Complete the reflow.
  557.  compile if EVERSION < '5.21'
  558.       .messageline=''                        -- Turn off the message.
  559.  compile else
  560.        'setmessageline '\0
  561.  compile endif
  562.  compile if EVERSION >= '5.53'
  563.       'toggleframe 2 'alt_R_active           -- Restore status of messageline.
  564.  compile else
  565.       'togglecontrol 8 'alt_R_active         -- Restore status of messageline.
  566.  compile endif
  567.       alt_R_active = ''
  568.       return
  569. compile else
  570.       activatefile tempofid                  -- Release tempo
  571.       .modify=0
  572.       'xcom q'
  573. compile endif
  574.    endif
  575.    if pblock_reflow(0,alt_R_space,tempofid) then
  576.       sayerror PBLOCK_ERROR__MSG      /* HurleyJ */
  577.       return
  578.    endif
  579. ;  if marktype() <> 'BLOCK' then
  580.       unmark
  581. ;  endif
  582. compile if EPM
  583.  compile if EVERSION >= '5.53'
  584.    alt_R_active = queryframecontrol(2)         -- Remember if messageline on or off
  585.    'toggleframe 2 1'                    -- Force it on
  586.  compile else
  587.    alt_R_active = querycontrol(8)         -- Remember if messageline on or off
  588.    'togglecontrol 8 1'                    -- Force it on
  589.  compile endif
  590.  compile if EVERSION < '5.21'
  591.    .messageline = BLOCK_REFLOW__MSG
  592.  compile else
  593.    'setmessageline' BLOCK_REFLOW__MSG
  594.  compile endif
  595. compile else
  596.    alt_R_active = 1
  597.    sayerror BLOCK_REFLOW__MSG
  598.    loop
  599.       k=getkey()
  600.       if k==a_r then  /* Alt-R ? */
  601.          call pblock_reflow(1,alt_R_space,tempofid)
  602.          leave
  603.       endif
  604.       if k==esc then  /* Esc ? */
  605.          /* release tempo */
  606.          activatefile tempofid
  607.          .modify=0
  608.          'xcom q'
  609.          unmark
  610.          sayerror NOFLOW__MSG
  611.          leave
  612.       endif
  613.       executekey k
  614.    endloop
  615.    alt_R_active = ''
  616. compile endif
  617.  
  618. def a_s=
  619.    call splitlines()
  620.  
  621. def a_t = call pcenter_mark()
  622.  
  623. def a_u=
  624.    unmark
  625. compile if EVERSION > 5
  626.    'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  627. compile endif
  628.  
  629. def a_w = call pmark_word()
  630.  
  631. ;  EPM:  Haven't yet figured out a way to do Alt-X=escape.  It used a getkey().
  632. compile if EVERSION < 5
  633. def a_x=escape
  634. compile endif
  635.  
  636. def a_y= call pbegin_mark()
  637.  
  638. compile if WANT_CHAR_OPS
  639. def a_z=mark_char
  640.  compile if EVERSION > 5
  641.    'Copy2SharBuff'       /* Copy mark to shared text buffer */
  642.  compile endif
  643. compile endif
  644.  
  645. compile if EVERSION < 5
  646. def backspace=
  647. compile else
  648. def backspace, s_backspace =
  649. compile endif
  650.  compile if WANT_STREAM_MODE = 'SWITCH'
  651.    universal stream_mode
  652.  compile endif
  653.  compile if WANT_CUA_MARKING = 'SWITCH'
  654.    universal CUA_marking_switch
  655.    if CUA_marking_switch then
  656.  compile endif
  657.  compile if WANT_CUA_MARKING
  658.   compile if EVERSION < 5
  659.    if command_state() then rubout; return; endif
  660.   compile endif
  661.    if process_mark_like_cua() then return; endif
  662.  compile endif
  663.  compile if WANT_CUA_MARKING = 'SWITCH'
  664.    endif
  665.  compile endif
  666. compile if WANT_STREAM_MODE
  667.  compile if WANT_STREAM_MODE = 'SWITCH'
  668.    if .col=1 & .line>1 & stream_mode $NOT_CMD_STATE then
  669.  compile else
  670.    if .col=1 & .line>1 $NOT_CMD_STATE then
  671.  compile endif
  672.       up
  673.       l=length(textline(.line))
  674.       join
  675.       .col=l+1
  676.    else
  677. compile endif
  678. compile if EVERSION >= '5.50'
  679.       old_level = .levelofattributesupport
  680.       if old_level & not (old_level%2 - 2*(old_level%4)) then
  681.          .levelofattributesupport = .levelofattributesupport + 2
  682.          .cursoroffset = -300
  683.       endif
  684. compile endif
  685.       rubout
  686. compile if EVERSION >= '5.50'
  687.       .levelofattributesupport = old_level
  688. compile endif
  689. compile if WANT_STREAM_MODE
  690.    endif
  691. compile endif
  692.  
  693. def c_2 = keyin \0                  -- C_2 enters a null.
  694. def c_6 = keyin \170                -- C_6 enters a "not" sign
  695. compile if EVERSION >= '5.50'
  696. def c_9 = keyin '{'
  697. def c_0 = keyin '}'
  698. compile endif
  699.  
  700. compile if WANT_WINDOWS
  701. def c_a= call pnextwindowstyle()  -- routine defined in WINDOW.E
  702. compile endif
  703.  
  704. compile if WANT_BOOKMARKS
  705. def c_B = 'listmark'
  706. compile endif
  707.  
  708. def c_backspace=
  709. compile if EVERSION >= '5.20'
  710.    undoaction 1, junk                -- Create a new state
  711. compile endif
  712. compile if EVERSION >= '5.50'
  713.    if .levelofattributesupport then
  714.       if (.line==.last and .line<>1) then       -- this is the last line
  715.          destinationLine=.line-1                -- and there is a previous line to store attributes on
  716.          getline prevline,DestinationLine
  717.          DestinationCol=length(prevline)+1      -- start search parameters
  718.                                                 -- destination of attributes
  719.          findoffset=-300                        -- start at the begin of the attr list
  720.          findline=.line                         -- of the first char on this line
  721.          findcolumn=1
  722.  
  723.          do forever        -- search until no more attr's (since this is last line)
  724.             FINDCLASS=0          -- 0 is anyclass
  725.             Attribute_action FIND_NEXT_ATTR_SUBOP, findclass, findoffset, findcolumn, findline
  726.             if not findclass or (findline<>.line) then  -- No attribute, or not on this line
  727.                leave
  728.             endif
  729.             query_attribute theclass,thevalue, thepush, findoffset, findcolumn, findline   -- push or pop?
  730.             if not thePush then       -- ..if its a pop attr and ..
  731.                matchClass=theClass
  732.                MatchOffset=FindOffset
  733.                MatchLine=FindLine
  734.                MatchColumn=FindColumn  -- ..and if its match is not on this line or at the destination
  735.                Attribute_Action FIND_MATCH_ATTR_SUBOP, MatchClass, MatchOffset, Matchcolumn, MatchLine
  736.                if ((Matchline==DestinationLine) and (Matchcolumn==destinationcol)) then
  737.                   -- then there is a cancellation of attributes
  738.                   Attribute_action Delete_ATTR_SUBOP, theclass, Findoffset, Findcolumn, Findline
  739.                   Attribute_action Delete_ATTR_SUBOP, Matchclass, Matchoffset, Matchcolumn, Matchline
  740.                elseif (MatchLine<>.line)  then
  741.                   -- .. then move attribute to destination (before attributes which have been scanned so its OK.)
  742.                   -- insert attr at the end of the attr list (offset=0)
  743.                   Insert_Attribute theclass, thevalue, 0, 0, DestinationCol, DestinationLine
  744.                   Attribute_action Delete_ATTR_SUBOP, theclass, Findoffset, Findcolumn, Findline
  745.                endif -- end if attr is on line or at destination
  746.             endif -- end if found attr is a pop
  747.          enddo  -- end search for attr's
  748.       elseif .line < .last then  -- put the attributes after the line since there may not
  749.                                  -- be a line before this line (as when .line==1)
  750.          DestinationCol=1
  751.          DestinationLine=.line+1         -- error point since this puts attr's after last line if .line=.last
  752.          findoffset=0                    -- cant make it .line-1 cause then present attributes there become
  753.          findline=.line                  -- after these attributes which is wrong
  754.          findcolumn=MAXCOL
  755.  
  756.          do forever
  757.             FINDCLASS=0
  758.             Attribute_action FIND_PREV_ATTR_SUBOP, findclass, findoffset, findcolumn, findline
  759.             if not findclass or (findline<>.line) then  -- No attribute, or not on this line
  760.                leave
  761.             endif
  762.              /* Move Attribute */
  763.             query_attribute theclass,thevalue, thepush, findoffset, findcolumn, findline
  764.             -- only move push/pop model attributes (tags are just deleted)
  765.             if ((thepush==0) or (thepush==1)) then
  766.                -- move attribute to destination, if cancellation delete both attributes
  767.                FastMoveAttrToBeg(theclass, thevalue, thepush, DestinationCol, DestinationLine, findcolumn, findline, findoffset)
  768.                findoffset=findoffset+1  -- since the attr rec was deleted and all attr rec's were shifted to fill the vacancy
  769.                                         -- and search is exclusive
  770.             endif
  771.          enddo
  772.       endif -- endif .line=.last and .line=1
  773.    endif -- .levelofattributesupport
  774. compile endif
  775.    delete
  776. compile if EVERSION >= '5.20'
  777.    undoaction 1, junk                -- Create a new state
  778. compile endif
  779. compile if EVERSION < 5
  780.    if command_state() then
  781.       begin_line
  782.    endif
  783. compile endif
  784.  
  785. def c_c=
  786. compile if EVERSION < 5
  787.   right
  788. compile else
  789.   'c'    -- EPM c_c is used for change next
  790. compile endif
  791.  
  792. ; Ctrl-D = word delete, thanks to Bill Brantley.
  793. def c_d =  /* delete from cursor until beginning of next word, UNDOable */
  794. compile if EVERSION < 5
  795.    if command_state() then
  796.       getcommand cmdline, begcur, cmdscrPos
  797.       lenCmdLine=length(cmdline)
  798.       if lenCmdLine >= begcur then
  799.          for i = begcur to lenCmdLine /* delete remainder of word */
  800.             if substr(cmdline,i,1)<>' ' then
  801.                deleteChar
  802.             else
  803.                leave
  804.             endif
  805.          endfor
  806.          for j = i to lenCmdLine /* delete delimiters following word */
  807.             if substr(cmdline,j,1)==' ' then
  808.                deleteChar
  809.             else
  810.                leave
  811.             endif
  812.          endfor
  813.       endif
  814.    else
  815. compile endif
  816.       getline line
  817.       begcur=.col
  818.       lenLine=length(line)
  819.       if lenLine >= begcur then
  820.          for i = begcur to lenLine /* delete remainder of word */
  821.             if substr(Line,i,1)<>' ' then
  822.                deleteChar
  823.             else
  824.                leave
  825.             endif
  826.          endfor
  827.          for j = i to lenLine /* delete delimiters following word */
  828.             if substr(Line,j,1)==' ' then
  829.                deleteChar
  830.             else
  831.                leave
  832.             endif
  833.          endfor
  834.       endif
  835. compile if EVERSION < 5
  836.    endif
  837. compile endif
  838.  
  839. compile if WANT_STACK_CMDS & not E3
  840. def c_down =
  841.    'pushpos'
  842. compile endif
  843.  
  844. compile if EVERSION >= '4.10'
  845. def c_e, c_del=erase_end_line  -- Ctrl-Del is the PM way.
  846. compile else
  847. def c_e=erase_end_line
  848. compile endif
  849.  
  850. compile if WANT_KEYWORD_HELP
  851. def c_h = 'kwhelp'
  852. compile endif
  853.  
  854. def c_end=
  855.  compile if WANT_STREAM_MODE = 'SWITCH'
  856.    universal stream_mode
  857. compile endif
  858. compile if WANT_CUA_MARKING
  859.    call begin_shift(startline, startcol, shift_flag)
  860. compile endif
  861. compile if WANT_STREAM_MODE = 'SWITCH'
  862.    if stream_mode then
  863. compile endif
  864. compile if WANT_STREAM_MODE
  865.       bottom; endline
  866. compile endif
  867. compile if WANT_STREAM_MODE = 'SWITCH'
  868.    else
  869. compile endif
  870. compile if WANT_STREAM_MODE <> 1
  871.       if .line=.last and .line then endline; endif
  872.       bottom
  873. compile endif
  874. compile if WANT_STREAM_MODE = 'SWITCH'
  875.    endif
  876. compile endif
  877. compile if WANT_CUA_MARKING
  878.    call end_shift(startline, startcol, shift_flag, 1)
  879. compile endif
  880.  
  881. compile if ENHANCED_ENTER_KEYS & C_ENTER_ACTION <> ''  -- define each key separately
  882. ; Nothing - defined below along with ENTER
  883. compile else
  884.  compile if EVERSION >= '4.10'
  885. def c_enter, c_pad_enter=     -- 4.10:  new key for enhanced keyboard
  886.  compile else
  887. def c_enter=
  888.  compile endif
  889.    call my_c_enter()
  890.  compile if E3 and SHOW_MODIFY_METHOD
  891.    call show_modify()
  892.  compile endif
  893. compile endif
  894.  
  895. def c_f=
  896. compile if defined(HIGHLIGHT_COLOR)
  897.    universal search_len
  898.  compile if EOS2
  899.    universal inKstring
  900.  compile endif
  901. compile endif
  902. compile if EVERSION > 5
  903.    sayerror 0
  904. compile endif
  905.    repeat_find       /* find next */
  906. compile if EVERSION < 5
  907.    if not rc then
  908.       cursor_data
  909.  compile if defined(HIGHLIGHT_COLOR)
  910.       refresh
  911.       sayat '', .windowy+.cursory-1,.windowx+.cursorx-1,
  912.             HIGHLIGHT_COLOR, min(search_len, .windowwidth - .cursorx + 1)
  913.   compile if EOS2
  914.       if inKstring <=0 then
  915.          k=mgetkey()
  916.          executekey k
  917.       endif
  918.   compile endif
  919.  compile endif
  920.    endif
  921. compile elseif defined(HIGHLIGHT_COLOR)
  922.    if not rc then
  923.  compile if EVERSION < '5.50'
  924.       refresh
  925.       sayat '', .cursory, .cursorx, HIGHLIGHT_COLOR, min(search_len, .windowwidth - .cursorx + 1)
  926.  compile elseif EVERSION >= '5.60'
  927.       circleit LOCATE_CIRCLE_STYLE, .line, .col, .col+getpminfo(EPMINFO_LSLENGTH)-1, LOCATE_CIRCLE_COLOR1, LOCATE_CIRCLE_COLOR2
  928.  compile elseif EVERSION >= '5.51'
  929.       circleit LOCATE_CIRCLE_STYLE, .line, .col, .col+getpminfo(EPMINFO_LSLENGTH)-1, HIGHLIGHT_COLOR
  930.  compile else
  931.       circleit LOCATE_CIRCLE_STYLE, .line, .col, .col+search_len-1, HIGHLIGHT_COLOR
  932.  compile endif
  933.    endif
  934. compile endif
  935.  
  936. def c_f1=
  937. compile if EVERSION < 5
  938.    call init_operation_on_commandline()
  939. compile endif
  940.    call psave_mark(save_mark)
  941.    call pmark_word()
  942.    call puppercase()
  943.    call prestore_mark(save_mark)
  944. compile if EVERSION < 5
  945.    call move_results_to_commandline()
  946. compile endif
  947.  
  948. def c_f2=
  949. compile if EVERSION < 5
  950.    call init_operation_on_commandline()
  951. compile endif
  952.    call psave_mark(save_mark)
  953.    call pmark_word()
  954.    call plowercase()
  955.    call prestore_mark(save_mark)
  956. compile if EVERSION < 5
  957.    call move_results_to_commandline()
  958. compile endif
  959.  
  960. def c_f3= call puppercase()
  961.  
  962. def c_f4= call plowercase()
  963.  
  964. def c_f5=
  965. compile if EVERSION < 5
  966.    call init_operation_on_commandline()
  967. compile endif
  968.    call pbegin_word()
  969. compile if EVERSION < 5
  970.    call move_results_to_commandline()
  971. compile endif
  972.  
  973. def c_f6=
  974. compile if EVERSION < 5
  975.    call init_operation_on_commandline()
  976. compile endif
  977.    call pend_word()
  978. compile if EVERSION < 5
  979.    call move_results_to_commandline()
  980. compile endif
  981.  
  982. compile if EPM
  983. def c_g='ring_more'
  984. compile endif
  985.  
  986. def c_home=
  987. compile if WANT_STREAM_MODE = 'SWITCH'
  988.    universal stream_mode
  989. compile endif
  990. compile if WANT_CUA_MARKING
  991.    call begin_shift(startline, startcol, shift_flag)
  992. compile endif
  993. compile if WANT_STREAM_MODE = 'SWITCH'
  994.    if stream_mode then
  995. compile endif
  996. compile if WANT_STREAM_MODE
  997.       top; begin_line
  998. compile endif
  999. compile if WANT_STREAM_MODE = 'SWITCH'
  1000.    else
  1001. compile endif
  1002. compile if WANT_STREAM_MODE <> 1
  1003.       if .line=1 then begin_line endif
  1004.       top
  1005. compile endif
  1006. compile if WANT_STREAM_MODE = 'SWITCH'
  1007.    endif
  1008. compile endif
  1009. compile if WANT_CUA_MARKING
  1010.    call end_shift(startline, startcol, shift_flag, 0)
  1011. compile endif
  1012.  
  1013. compile if WANT_WINDOWS
  1014. def c_h=call psplith()            -- routine defined in WINDOW.E
  1015. compile endif
  1016.  
  1017. def c_k=      -- Duplicate a line
  1018.   getline line
  1019.   insertline line,.line+1
  1020.  
  1021. def c_l =
  1022.    if .line then
  1023.       getline line
  1024. compile if EPM
  1025.       'commandline 'line
  1026. compile else
  1027.       if not command_state() then
  1028.          cursor_command
  1029.          begin_line;erase_end_line
  1030.       endif
  1031.       keyin line
  1032. compile endif
  1033.    endif
  1034.  
  1035. def c_left=
  1036. compile if WANT_STREAM_MODE = 'SWITCH'
  1037.    universal stream_mode
  1038. compile endif
  1039. compile if EVERSION < 5
  1040.    call init_operation_on_commandline()
  1041. compile endif
  1042. compile if WANT_CUA_MARKING
  1043.    call begin_shift(startline, startcol, shift_flag)
  1044. compile endif
  1045. compile if WANT_STREAM_MODE
  1046.    if not .line then
  1047.       begin_line
  1048.  compile if WANT_STREAM_MODE = 'SWITCH'
  1049.    elseif .line>1 & .col=max(1,verify(textline(.line),' ')) & stream_mode $NOT_CMD_STATE then
  1050.  compile else
  1051.    elseif .line>1 & .col=max(1,verify(textline(.line),' ')) $NOT_CMD_STATE then
  1052.  compile endif
  1053.       up; end_line
  1054.    endif
  1055. compile endif
  1056.    backtab_word
  1057. compile if EVERSION < 5
  1058.    call move_results_to_commandline()
  1059. compile endif
  1060. compile if WANT_CUA_MARKING
  1061.    call end_shift(startline, startcol, shift_flag, 0)
  1062. compile endif
  1063.  
  1064. compile if WANT_BOOKMARKS
  1065. def c_m = 'setmark'
  1066. compile else  -- [The following doesn't apply to EPM.]
  1067. ; This C-M definition allows external cut-and-paste utilities to
  1068. ; feed text into E via the keyboard stream.  Most such utilities end each line
  1069. ; of text with ASCII character 13.  This definition is needed because E
  1070. ; distinguishes that as a different key (Ctrl-M) than Enter.
  1071. def c_m =
  1072.    insert
  1073. compile endif
  1074.  
  1075. def c_pgup=
  1076. compile if WANT_CUA_MARKING
  1077.  compile if WANT_CUA_MARKING = 'SWITCH'
  1078.    universal CUA_marking_switch
  1079.    if CUA_marking_switch then
  1080.  compile endif
  1081.       unmark
  1082.  compile if WANT_CUA_MARKING = 'SWITCH'
  1083.    endif
  1084.  compile endif
  1085. compile endif
  1086.    .cursory=1
  1087.  
  1088. def c_pgdn=
  1089. compile if WANT_CUA_MARKING
  1090.  compile if WANT_CUA_MARKING = 'SWITCH'
  1091.    universal CUA_marking_switch
  1092.    if CUA_marking_switch then
  1093.  compile endif
  1094.       unmark
  1095.  compile if WANT_CUA_MARKING = 'SWITCH'
  1096.    endif
  1097.  compile endif
  1098. compile endif
  1099.    .cursory=.windowheight
  1100.  
  1101. compile if EVERSION < 5
  1102. /************************************************************/
  1103. /* Create a string of keys in Kstring variable.             */
  1104. /* All control keys have the same character (X'00') as the  */
  1105. /* first character of a two-character string.               */
  1106. /*                                                          */
  1107. /* The number of keys that may be stored is given by:       */
  1108. /*           256 > n + 2*e                                  */
  1109. /* where:                                                   */
  1110. /*       n are normal data keys (one byte from BIOS)        */
  1111. /*       e are extended code keys (two bytes from BIOS)     */
  1112. /************************************************************/
  1113. def c_r=
  1114.    universal Kstring,Kins_state,Kcom_state,inKstring
  1115.  
  1116.    inKstring=-1      /* Set recording flag; see defproc mgetkey(). */
  1117.    sayerror CTRL_R__MSG
  1118.    oldKins_state=Kins_state
  1119.    oldKstring   =Kstring
  1120.    oldKcom_state=Kcom_state
  1121.    Kins_state   =insert_state()
  1122.    Kstring      =''
  1123.    Kcom_state   =command_state()
  1124.    Kct=0
  1125.    loop
  1126.       k=getkey()
  1127.       if k==c_r then  /* Ctrl-R ? */
  1128.          sayerror REMEMBERED__MSG
  1129.          leave
  1130.       endif
  1131.       if k==c_t then  /* Ctrl-T ? */
  1132.          leave
  1133.       endif
  1134.       if k==c_c then  /* cancel? */
  1135.          Kstring   =oldKstring
  1136.          Kins_state=oldKins_state
  1137.          Kcom_state=oldKcom_state
  1138.          sayerror CANCELLED__MSG'  'OLD_KEPT__MSG
  1139.          leave
  1140.       endif
  1141.       Kstring=Kstring||k
  1142.       Kct=length(Kstring)
  1143.       executekey k         /* execute AFTER adding to string */
  1144.       if Kct > MAXCOL then
  1145.          sayerror CTRL_R_ABORT__MSG
  1146.          Kstring=oldKstring
  1147.          Kins_state=oldKins_state
  1148.          Kcom_state=oldKcom_state
  1149.          loop
  1150.             k=getkey()
  1151.             if k==esc or k==c_c then leave endif   /* accept either */
  1152.          endloop
  1153.          sayerror OLD_KEPT__MSG
  1154.          leave
  1155.       endif
  1156.    endloop
  1157.    inKstring=0       /* lower state flag */
  1158.    if k==c_t then    /* Was it Ctrl-T? */
  1159.       sayerror 0     /* refresh the function keys */
  1160.       executekey k
  1161.    endif
  1162. compile endif
  1163.  
  1164. compile if EPM
  1165. def c_r
  1166.    -- Query to see if we are already in recording
  1167.    if windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  1168.                     5393,
  1169.                     0,
  1170.                     0)
  1171.    then
  1172.       call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  1173.                          5392,
  1174.                          0,
  1175.                          0)
  1176.       sayerror REMEMBERED__MSG
  1177.    else
  1178.       sayerror CTRL_R__MSG
  1179.       call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  1180.                          5390,
  1181.                          0,
  1182.                          0)
  1183.    endif
  1184. compile endif
  1185.  
  1186. def c_right=
  1187. compile if WANT_STREAM_MODE = 'SWITCH'
  1188.    universal stream_mode
  1189. compile endif
  1190. compile if EVERSION < 5
  1191.    call init_operation_on_commandline()
  1192. compile endif
  1193. compile if WANT_CUA_MARKING
  1194.    call begin_shift(startline, startcol, shift_flag)
  1195. compile endif
  1196. compile if WANT_STREAM_MODE
  1197.    getline line
  1198.  compile if WANT_STREAM_MODE = 'SWITCH'
  1199.    if not .line | lastpos(' ',line)<.col & .line<.last & stream_mode $NOT_CMD_STATE then
  1200.  compile else
  1201.    if not .line | lastpos(' ',line)<.col & .line<.last $NOT_CMD_STATE then
  1202.  compile endif
  1203.       down
  1204.       call pfirst_nonblank()
  1205.    else
  1206. compile endif
  1207.       tab_word
  1208. compile if WANT_STREAM_MODE
  1209.    endif
  1210. compile endif
  1211. compile if EVERSION < 5
  1212.    call move_results_to_commandline()
  1213. compile endif
  1214. compile if WANT_CUA_MARKING
  1215.    call end_shift(startline, startcol, shift_flag, 1)
  1216. compile endif
  1217.  
  1218. -- Pop up Search dialog
  1219. compile if EVERSION > 5
  1220. def c_s=
  1221.    'searchdlg'
  1222. compile endif
  1223.  
  1224. compile if EVERSION < 5
  1225. /************************************************************/
  1226. /* Execute the string of keys in Kstring variable.          */
  1227. /* All control keys have the same character (X'00') as the  */
  1228. /* first character of a two-character string                */
  1229. /*                                                          */
  1230. /* The number of keys that may be stored is given by:       */
  1231. /*           256 > n + 2*e                                  */
  1232. /* where:                                                   */
  1233. /*       n are normal data keys (one byte from BIOS)        */
  1234. /*       c are extended code keys (two bytes from BIOS)     */
  1235. /************************************************************/
  1236. def c_t=
  1237.    universal Kstring,Kins_state,Kcom_state,inKstring
  1238.  
  1239.    if Kstring=='' then
  1240.       sayerror NO_CTRL_R__MSG              /* HurleyJ */
  1241.       return
  1242.    endif   /* Has a string been recorded? */
  1243.    if Kins_state/==insert_state()   then  insert_toggle endif
  1244.    if Kcom_state/==command_state() then command_toggle endif
  1245.  
  1246.    inKstring=1    /* Set replaying flag; see defproc mgetkey(). */
  1247.    loop
  1248.       k=substr(Kstring,inKstring,1)
  1249.       ksize=1
  1250.       if k==substr(esc,1,1) then       /* extended key ? */
  1251.          k=substr(Kstring,inKstring,2) /* Yes, 2 bytes for extended key. */
  1252.          ksize=2
  1253.       endif
  1254.       inKstring=inKstring+ksize        /* bump index AFTER execution */
  1255.       executekey k
  1256.       if inKstring > length(Kstring) then leave endif
  1257.    endloop
  1258.    inKstring=0
  1259. compile endif
  1260.  
  1261. compile if EPM
  1262. def c_t
  1263.    call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  1264.                       5392,
  1265.                       0,
  1266.                       0)
  1267.    call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  1268.                       5391,
  1269.                       0,
  1270.                       0)
  1271. compile endif
  1272.  
  1273. compile if not E3
  1274. def c_tab = keyin \9
  1275. compile endif
  1276.  
  1277. compile if EVERSION >= '5.20'
  1278. def c_u = 'undodlg'
  1279. compile endif
  1280.  
  1281. compile if WANT_STACK_CMDS & not E3
  1282. def c_up =
  1283.    'poppos'
  1284. compile endif
  1285.  
  1286. compile if WANT_WINDOWS
  1287. def c_v= call psplitv()           -- routine defined in WINDOW.E
  1288. def c_w= call pnextwindow()       -- routine defined in WINDOW.E
  1289. def c_z= call pzoom()             -- routine defined in WINDOW.E
  1290. compile endif
  1291.  
  1292. compile if EPM
  1293. def c_W=
  1294.    if marktype()<>'' then
  1295.       sayerror -279  -- 'Text already marked'
  1296.       return
  1297.    endif
  1298.    if find_token(startcol, endcol) then
  1299.       getfileid fid
  1300.  compile if WANT_CHAR_OPS
  1301.       call pset_mark(.line, .line, startcol, endcol, 'CHAR', fid)
  1302.  compile else
  1303.       call pset_mark(.line, .line, startcol, endcol, 'BLOCK', fid)
  1304.  compile endif
  1305.       'Copy2SharBuff'       /* Copy mark to shared text buffer */
  1306.    endif
  1307. compile endif
  1308.  
  1309. compile if EVERSION >= '5.50'
  1310. def c_Y = 'fontlist'
  1311. compile endif
  1312.  
  1313. def del=
  1314. compile if WANT_STREAM_MODE = 'SWITCH'
  1315.    universal stream_mode
  1316. compile endif
  1317. compile if WANT_CUA_MARKING & EPM
  1318.  compile if WANT_CUA_MARKING = 'SWITCH'
  1319.    universal CUA_marking_switch
  1320.    if marktype() & CUA_marking_switch then    -- If there's a mark, then
  1321.  compile else
  1322.    if marktype() then    -- If there's a mark, then
  1323.  compile endif
  1324.       if process_mark_like_cua() then return; endif
  1325.    endif
  1326. compile endif
  1327. compile if WANT_STREAM_MODE
  1328.    if .line then
  1329.       l=length(textline(.line))
  1330.    else
  1331.       l=.col    -- make the following IF fail
  1332.    endif
  1333.  compile if WANT_STREAM_MODE = 'SWITCH'
  1334.    if .col>l & stream_mode $NOT_CMD_STATE then
  1335.  compile else
  1336.    if .col>l $NOT_CMD_STATE then
  1337.  compile endif
  1338.       join
  1339.       .col=l+1
  1340.    else
  1341. compile endif  -- WANT_STREAM_MODE
  1342. compile if EVERSION >= '5.50'
  1343.       old_level = .levelofattributesupport
  1344.       if old_level & not (old_level%2 - 2*(old_level%4)) then
  1345.          .levelofattributesupport = .levelofattributesupport + 2
  1346.          .cursoroffset = 0
  1347.       endif
  1348. compile endif
  1349.       delete_char
  1350. compile if EVERSION >= '5.50'
  1351.       .levelofattributesupport = old_level
  1352. compile endif
  1353. compile if WANT_STREAM_MODE
  1354.    endif
  1355. compile endif
  1356.  
  1357. def down=
  1358. compile if WANT_CUA_MARKING
  1359.  compile if WANT_CUA_MARKING = 'SWITCH'
  1360.    universal CUA_marking_switch
  1361.    if CUA_marking_switch then
  1362.  compile endif
  1363.       unmark
  1364.  compile if WANT_CUA_MARKING = 'SWITCH'
  1365.    endif
  1366.  compile endif
  1367. compile endif
  1368. compile if WANT_STREAM_MODE
  1369.    call updownkey(1)
  1370. compile else
  1371.    down
  1372. compile endif
  1373.  
  1374. compile if WANT_CUA_MARKING & EPM
  1375. def s_down=
  1376.  compile if WANT_CUA_MARKING = 'SWITCH'
  1377.    universal CUA_marking_switch
  1378.  compile endif
  1379.    startline = .line; startcol = .col
  1380. compile if WANT_STREAM_MODE
  1381.    call updownkey(1)
  1382. compile else
  1383.    down
  1384. compile endif
  1385. ;compile if WANT_CUA_MARKING = 'SWITCH'
  1386. ;  if CUA_marking_switch then
  1387. ;compile endif
  1388.    if startline then call extend_mark(startline, startcol, 1); endif
  1389. ;compile if WANT_CUA_MARKING = 'SWITCH'
  1390. ;  endif
  1391. ;compile endif
  1392. compile endif
  1393.  
  1394. def end=
  1395. compile if WANT_CUA_MARKING
  1396.  compile if WANT_CUA_MARKING = 'SWITCH'
  1397.    universal CUA_marking_switch
  1398.    if CUA_marking_switch then
  1399.  compile endif
  1400.       unmark
  1401.  compile if WANT_CUA_MARKING = 'SWITCH'
  1402.    endif
  1403.  compile endif
  1404. compile endif
  1405.    end_line
  1406.  
  1407. compile if WANT_CUA_MARKING & EPM
  1408. def s_end =
  1409.    startline = .line; startcol = .col
  1410.    end_line
  1411.    call extend_mark(startline, startcol, 1)
  1412. compile endif
  1413.  
  1414. compile if ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''  -- define each key separately
  1415. def enter =
  1416.    universal enterkey
  1417.  compile if WANT_EPM_SHELL & EPM_SHELL_PROMPT = '@prompt epm: $p $g'
  1418.    if leftstr(.filename, 15) = ".command_shell_" then
  1419.       shellnum=substr(.filename,16)
  1420.       getline line
  1421.       x = pos('>',line)
  1422.       text = substr(line,x+1)
  1423.       if leftstr(line,5)='epm: ' & x & shellnum & text<>'' then
  1424.          if .line=.last then .col=x+1; erase_end_line; endif
  1425.          'shell_write' shellnum text
  1426.       else
  1427.          call enter_common(enterkey)
  1428.       endif
  1429.    else
  1430.  compile endif
  1431.       call enter_common(enterkey)
  1432.  compile if WANT_EPM_SHELL & EPM_SHELL_PROMPT = '@prompt epm: $p $g'
  1433.   endif
  1434.  compile endif
  1435. def a_enter =
  1436.    universal a_enterkey
  1437.    call enter_common(a_enterkey)
  1438. def c_enter =
  1439.    universal c_enterkey
  1440.    call enter_common(c_enterkey)
  1441. def s_enter =
  1442.    universal s_enterkey
  1443.    call enter_common(s_enterkey)
  1444. def padenter =
  1445.    universal padenterkey
  1446.    call enter_common(padenterkey)
  1447. def a_padenter =
  1448.    universal a_padenterkey
  1449.    call enter_common(a_padenterkey)
  1450. def c_padenter =
  1451.    universal c_padenterkey
  1452.    call enter_common(c_padenterkey)
  1453. def s_padenter =
  1454.    universal s_padenterkey
  1455.    call enter_common(s_padenterkey)
  1456. compile else
  1457.  compile if EVERSION >= '4.10'
  1458.   compile if EVERSION < 5
  1459. def enter, pad_enter, a_enter, a_pad_enter=  --4.10: new enhanced keyboard keys
  1460.   compile else
  1461. def enter, pad_enter, a_enter, a_pad_enter, s_enter, s_padenter=
  1462.   compile endif
  1463.  compile else
  1464. def enter=
  1465.  compile endif
  1466.  compile if WANT_EPM_SHELL & EPM_SHELL_PROMPT = '@prompt epm: $p $g'
  1467.    if leftstr(.filename, 15) = ".command_shell_" then
  1468.       shellnum=substr(.filename,16)
  1469.       getline line
  1470.       x = pos('>',line)
  1471.       text = substr(line,x+1)
  1472.       if leftstr(line,5)='epm: ' & x & shellnum & text<>'' then
  1473.          if .line=.last then .col=x+1; erase_end_line; endif
  1474.          'shell_write' shellnum text
  1475.       else
  1476.          call my_enter()
  1477.       endif
  1478.    else
  1479.  compile endif
  1480.    call my_enter()
  1481.  compile if E3 and SHOW_MODIFY_METHOD
  1482.    call show_modify()
  1483.  compile endif
  1484.  compile if WANT_EPM_SHELL & EPM_SHELL_PROMPT = '@prompt epm: $p $g'
  1485.   endif
  1486.  compile endif
  1487. compile endif  -- ENHANCED_ENTER_KEYS & ENTER_ACTION <> ''
  1488.  
  1489. compile if not defined(NO_ESCAPE)
  1490.    const NO_ESCAPE = 0
  1491. compile endif
  1492.  
  1493. compile if EVERSION < 5
  1494. def esc=
  1495.    command_toggle
  1496.  compile if E3 and SHOW_MODIFY_METHOD
  1497.    call show_modify()
  1498.  compile endif
  1499. compile else  -- else EPM
  1500.  compile if NO_ESCAPE  -- Blame CUA  :-(
  1501. def esc=
  1502.   compile if TOGGLE_ESCAPE
  1503.    universal ESCAPE_KEY
  1504.   compile endif
  1505.  compile else
  1506. def esc, C_I=
  1507.  compile endif
  1508.    universal alt_R_active
  1509.  
  1510.    sayerror 0
  1511.    if alt_R_active<>'' then
  1512.  compile if EVERSION < '5.21'
  1513.       .messageline=''                        -- Turn off the message.
  1514.  compile else
  1515.        'setmessageline '\0
  1516.  compile endif
  1517.  compile if EVERSION >= '5.53'
  1518.       'toggleframe 2 'alt_R_active         -- Restore status of messageline.
  1519.  compile else
  1520.       'togglecontrol 8 'alt_R_active         -- Restore status of messageline.
  1521.  compile endif
  1522.       alt_R_active = ''
  1523.  compile if NO_ESCAPE
  1524.   compile if TOGGLE_ESCAPE
  1525.    elseif ESCAPE_KEY then
  1526.       'commandline'
  1527.   compile endif
  1528.    endif
  1529. def c_I='commandline'
  1530.  compile else
  1531.    else
  1532.       'commandline'
  1533.    endif
  1534.  compile endif  -- no Escape
  1535. compile endif  -- EPM
  1536.  
  1537. def f1= 'help'
  1538.  
  1539. def f2=
  1540. compile if SMARTSAVE
  1541.    if .modify then           -- Modified since last Save?
  1542.       'Save'                 --   Yes - save it
  1543.    else
  1544.  compile if EPM
  1545.       'commandline Save '
  1546.  compile else
  1547.       if not command_state() then
  1548.          cursor_command
  1549.       endif
  1550.       begin_line;erase_end_line
  1551.       keyin 'Save '
  1552.  compile endif
  1553.       sayerror 'No changes.  Press Enter to Save anyway.'
  1554.    endif
  1555. compile else
  1556.    'Save'
  1557. compile endif
  1558.  
  1559. def f3= 'quit'
  1560.  
  1561. def f4=
  1562. compile if SMARTFILE
  1563.    if .modify then           -- Modified since last Save?
  1564.       'File'                 --   Yes - save it and quit.
  1565.    else
  1566.       'Quit'                 --   No - just quit.
  1567.    endif
  1568. compile else
  1569.    'File'
  1570. compile endif
  1571.  
  1572. compile if EVERSION < 5
  1573. def f7=cursor_command; delete; begin_line; keyin 'Name '
  1574. def f8=cursor_command; delete; begin_line; keyin 'Edit '
  1575. compile else
  1576.                     /* keys by EPM */
  1577. def f5, c_O='OPENDLG'
  1578. def f7='rename'
  1579. def f8=
  1580.  compile if RING_OPTIONAL
  1581.    universal ring_enabled
  1582.    if not ring_enabled then
  1583.       sayerror NO_RING__MSG
  1584.       return
  1585.    endif
  1586.  compile endif
  1587.    'OPENDLG EDIT'
  1588. compile endif
  1589.  
  1590. compile if EVERSION < 5
  1591. def f9=undo
  1592. compile else
  1593. def f9, a_backspace = undo
  1594. compile endif
  1595.  
  1596.  
  1597. compile if EVERSION < 5
  1598.  compile if EVERSION < '4.10'          -- Early E doesn't support enh. kbd.
  1599. def f10,c_N= call pnextfile()             -- routine defined in WINDOW.E
  1600.  compile else
  1601. def f10,f12,c_N= call pnextfile()         -- routine defined in WINDOW.E
  1602.  compile endif
  1603. compile else
  1604. def f10,f12,c_N=   -- F10 is usual E default; F12 for enhanced kbd, c_N for EPM.
  1605.    nextfile
  1606. compile endif
  1607.  
  1608.  
  1609. def home =
  1610. compile if WANT_CUA_MARKING
  1611.  compile if WANT_CUA_MARKING = 'SWITCH'
  1612.    universal CUA_marking_switch
  1613.    if CUA_marking_switch then
  1614.  compile endif
  1615.       unmark
  1616.  compile if WANT_CUA_MARKING = 'SWITCH'
  1617.    endif
  1618.  compile endif
  1619. compile endif
  1620.    begin_line
  1621.  
  1622. compile if WANT_CUA_MARKING & EPM
  1623. def s_home =
  1624.    startline = .line; startcol = .col
  1625.    begin_line
  1626.    call extend_mark(startline, startcol, 0)
  1627. compile endif
  1628.  
  1629. def ins=insert_toggle
  1630. compile if EVERSION >='5.50'
  1631.    call fixup_cursor()
  1632. compile endif
  1633.  
  1634. def left=
  1635. compile if WANT_CUA_MARKING = 'SWITCH'
  1636.    universal CUA_marking_switch
  1637. compile endif
  1638. compile if WANT_STREAM_MODE = 'SWITCH'
  1639.    universal stream_mode
  1640.    if .line>1 & .col=1 & stream_mode $NOT_CMD_STATE then up; end_line; else left; endif
  1641. compile elseif WANT_STREAM_MODE
  1642.    if .line>1 & .col=1 $NOT_CMD_STATE then up; end_line; else left; endif
  1643. compile else
  1644.    left
  1645. compile endif
  1646. compile if WANT_CUA_MARKING
  1647.  compile if WANT_CUA_MARKING = 'SWITCH'
  1648.    if CUA_marking_switch then
  1649.  compile endif
  1650.       unmark
  1651.  compile if WANT_CUA_MARKING = 'SWITCH'
  1652.    endif
  1653.  compile endif
  1654. compile endif
  1655.  
  1656. compile if WANT_CUA_MARKING & EPM
  1657. def s_left =
  1658.    startline = .line; startcol = .col
  1659.    if .line>1 & .col=1 then up; end_line; else left; endif
  1660.    call extend_mark(startline, startcol, 0)
  1661. compile endif
  1662.  
  1663. compile if EVERSION < 5
  1664. def padminus=keyin '-'
  1665. def padplus=keyin '+'
  1666.  compile if EVERSION >= '4.10'
  1667. def padslash, c_padslash =keyin '/'     -- 4.10 for enhanced keyboard
  1668.  compile endif
  1669. def padstar=keyin '*'
  1670. compile endif
  1671.  
  1672. def pgup =
  1673. compile if WANT_CUA_MARKING
  1674.  compile if WANT_CUA_MARKING = 'SWITCH'
  1675.    universal CUA_marking_switch
  1676.    if CUA_marking_switch then
  1677.  compile endif
  1678.       unmark
  1679.  compile if WANT_CUA_MARKING = 'SWITCH'
  1680.    endif
  1681.  compile endif
  1682. compile endif
  1683.    page_up
  1684.  
  1685. def pgdn =
  1686. compile if WANT_CUA_MARKING
  1687.  compile if WANT_CUA_MARKING = 'SWITCH'
  1688.    universal CUA_marking_switch
  1689.    if CUA_marking_switch then
  1690.  compile endif
  1691.       unmark
  1692.  compile if WANT_CUA_MARKING = 'SWITCH'
  1693.    endif
  1694.  compile endif
  1695. compile endif
  1696.    page_down
  1697.  
  1698. compile if EPM
  1699. def s_pgup=
  1700.  compile if TOP_OF_FILE_VALID = 'STREAM' & WANT_STREAM_MODE = 'SWITCH'
  1701.    universal stream_mode
  1702.  compile endif
  1703.    startline = .line; startcol = .col
  1704.    page_up
  1705.    if .line then call extend_mark(startline, startcol, 0); endif
  1706.  compile if TOP_OF_FILE_VALID = 'STREAM' & WANT_STREAM_MODE = 'SWITCH'
  1707.    if not .line & stream_mode then '+1'; endif
  1708.  compile elseif not TOP_OF_FILE_VALID
  1709.    if not .line then '+1'; endif
  1710.  compile endif
  1711.  
  1712. def s_pgdn=
  1713.    startline = .line; startcol = .col
  1714.    page_down
  1715.    if startline then call extend_mark(startline, startcol, 1); endif
  1716. compile endif
  1717.  
  1718. def right=
  1719. compile if WANT_STREAM_MODE = 'SWITCH'
  1720.    universal stream_mode
  1721. compile endif
  1722. compile if WANT_CUA_MARKING
  1723.  compile if WANT_CUA_MARKING = 'SWITCH'
  1724.    universal CUA_marking_switch
  1725.    if CUA_marking_switch then
  1726.  compile endif
  1727.       unmark
  1728.  compile if WANT_CUA_MARKING = 'SWITCH'
  1729.    endif
  1730.  compile endif
  1731. compile endif
  1732. compile if WANT_STREAM_MODE
  1733.    if .line then l=length(textline(.line)); else l=.col; endif
  1734.  compile if WANT_STREAM_MODE = 'SWITCH'
  1735.    if .line<.last & .col>l & stream_mode $NOT_CMD_STATE then
  1736.  compile else
  1737.    if .line<.last & .col>l $NOT_CMD_STATE then
  1738.  compile endif
  1739.       down; begin_line
  1740.  compile if WANT_STREAM_MODE = 'SWITCH'
  1741.    elseif .line=.last & .col>l & stream_mode $NOT_CMD_STATE then   -- nop
  1742.  compile else
  1743.    elseif .line=.last & .col>l $NOT_CMD_STATE then  -- nop
  1744.  compile endif
  1745.    else
  1746.       right
  1747.    endif
  1748. compile else
  1749.    right
  1750. compile endif
  1751.  
  1752. compile if WANT_CUA_MARKING & EPM
  1753. def s_right =
  1754.    startline = .line; startcol = .col
  1755.    if .line then l=length(textline(.line)); else l=.col; endif
  1756.    if .line<.last & .col>l then
  1757.       down; begin_line
  1758.    elseif .line<>.last | .col<=l then
  1759.       right
  1760.    endif
  1761.    call extend_mark(startline, startcol, 1)
  1762. compile endif
  1763.  
  1764.  
  1765. def s_f1= /* scroll left */
  1766. compile if WANT_CUA_MARKING
  1767.  compile if WANT_CUA_MARKING = 'SWITCH'
  1768.    universal CUA_marking_switch
  1769.    if CUA_marking_switch then
  1770.  compile endif
  1771.       unmark
  1772.  compile if WANT_CUA_MARKING = 'SWITCH'
  1773.    endif
  1774.  compile endif
  1775. compile endif
  1776.    oldcursorx=.cursorx
  1777.    if .col-.cursorx then
  1778.       .col=.col-.cursorx
  1779.       .cursorx=oldcursorx
  1780.    elseif .cursorx>1 then
  1781.       left
  1782.    endif
  1783.  
  1784. def s_f2= /* scroll right */
  1785. compile if WANT_CUA_MARKING
  1786.  compile if WANT_CUA_MARKING = 'SWITCH'
  1787.    universal CUA_marking_switch
  1788.    if CUA_marking_switch then
  1789.  compile endif
  1790.       unmark
  1791.  compile if WANT_CUA_MARKING = 'SWITCH'
  1792.    endif
  1793.  compile endif
  1794. compile endif
  1795.   oldcursorx=.cursorx
  1796.   a=.col+.windowwidth-.cursorx+1
  1797.   if a<=MAXCOL then
  1798.      .col=a
  1799.      .cursorx=oldcursorx
  1800.   elseif .col<MAXCOL then
  1801.      right
  1802.   endif
  1803.  
  1804. def s_f3= /* scroll up */
  1805. compile if WANT_CUA_MARKING
  1806.  compile if WANT_CUA_MARKING = 'SWITCH'
  1807.    universal CUA_marking_switch
  1808.    if CUA_marking_switch then
  1809.  compile endif
  1810.       unmark
  1811.  compile if WANT_CUA_MARKING = 'SWITCH'
  1812.    endif
  1813.  compile endif
  1814. compile endif
  1815.   oldcursory=.cursory
  1816.   if .line-.cursory>-1 then
  1817.      .cursory=1
  1818.      up
  1819.      .cursory=oldcursory
  1820.   elseif .line then
  1821.      up
  1822.   endif
  1823.  
  1824. def s_f4= /* scroll down */
  1825. compile if WANT_CUA_MARKING
  1826.  compile if WANT_CUA_MARKING = 'SWITCH'
  1827.    universal CUA_marking_switch
  1828.    if CUA_marking_switch then
  1829.  compile endif
  1830.       unmark
  1831.  compile if WANT_CUA_MARKING = 'SWITCH'
  1832.    endif
  1833.  compile endif
  1834. compile endif
  1835.    oldcursory=.cursory
  1836.    if .line -.cursory+.windowheight<.last then
  1837.       .cursory=.windowheight
  1838.       down
  1839.       .cursory=oldcursory
  1840.    elseif .line<.last then
  1841.       down
  1842.    endif
  1843.  
  1844. def s_f5= /* center current line */
  1845. compile if WANT_CUA_MARKING
  1846.  compile if WANT_CUA_MARKING = 'SWITCH'
  1847.    universal CUA_marking_switch
  1848.    if CUA_marking_switch then
  1849.  compile endif
  1850.       unmark
  1851.  compile if WANT_CUA_MARKING = 'SWITCH'
  1852.    endif
  1853.  compile endif
  1854. compile endif
  1855.    oldline=.line
  1856.    .cursory=.windowheight%2
  1857.    oldline
  1858.  
  1859. compile if WANT_TAGS
  1860. def s_f6 = 'findtag'
  1861. def s_f7 = 'findtag *'
  1862. def s_f8 = 'tagsfile'
  1863. def s_f9 = 'maketags *'
  1864. compile endif -- WANT_TAGS
  1865.  
  1866. compile if EVERSION < 5
  1867. def s_pad5=keyin '5'
  1868. compile endif
  1869.  
  1870. def s_tab=
  1871.    universal matchtab_on
  1872. compile if WANT_CUA_MARKING
  1873.  compile if WANT_CUA_MARKING = 'SWITCH'
  1874.    universal CUA_marking_switch
  1875.    if CUA_marking_switch then
  1876.  compile endif
  1877.       unmark
  1878.  compile if WANT_CUA_MARKING = 'SWITCH'
  1879.    endif
  1880.  compile endif
  1881. compile endif
  1882. compile if EVERSION < 5
  1883.    call init_operation_on_commandline()
  1884. compile endif
  1885.    if matchtab_on & .line>1 $NOT_CMD_STATE then
  1886.       up
  1887.       backtab_word
  1888.       down
  1889.    else
  1890.       backtab
  1891.    endif
  1892. compile if EVERSION < 5
  1893.    call move_results_to_commandline()
  1894. compile endif
  1895.  
  1896. compile if EPM
  1897. def space, s_space, c_space  /* New in EPM.  Space is a virtual key under PM.*/
  1898.  compile if WANT_CUA_MARKING
  1899.   compile if WANT_CUA_MARKING = 'SWITCH'
  1900.    universal CUA_marking_switch
  1901.    if CUA_marking_switch then
  1902.   compile endif
  1903.       call process_mark_like_cua()
  1904.   compile if WANT_CUA_MARKING = 'SWITCH'
  1905.    endif
  1906.   compile endif
  1907.  compile endif
  1908.  compile if EVERSION >= '5.20'
  1909.    k=lastkey(1)
  1910.  compile endif
  1911.    keyin ' '
  1912.  compile if EVERSION >= '5.20'
  1913.    if k<>' ' then
  1914.       undoaction 1, junk                -- Create a new state
  1915.    endif
  1916.  compile endif
  1917. compile endif
  1918.  
  1919. def tab=
  1920. compile if WANT_STREAM_MODE = 'SWITCH'
  1921.    universal stream_mode
  1922. compile endif
  1923.    universal matchtab_on
  1924. compile if TOGGLE_TAB
  1925.    universal TAB_KEY
  1926. compile endif
  1927. compile if WANT_CUA_MARKING = 'SWITCH'
  1928.    universal CUA_marking_switch
  1929. compile endif     -------Start of logic:
  1930. compile if TOGGLE_TAB
  1931.    if TAB_KEY then
  1932.  compile if WANT_CUA_MARKING
  1933.   compile if WANT_CUA_MARKING = 'SWITCH'
  1934.       if CUA_marking_switch then
  1935.   compile endif
  1936.           process_key(\9)
  1937.   compile if WANT_CUA_MARKING = 'SWITCH'
  1938.       else
  1939.   compile endif
  1940.  compile endif  -- WANT_CUA_MARKING
  1941.          keyin \9
  1942.  compile if WANT_CUA_MARKING = 'SWITCH'
  1943.       endif
  1944.  compile endif
  1945.    else
  1946. compile endif  -- TOGGLE_TAB
  1947. compile if WANT_CUA_MARKING
  1948.  compile if WANT_CUA_MARKING = 'SWITCH'
  1949.    if CUA_marking_switch then
  1950.  compile endif
  1951.       unmark
  1952.  compile if WANT_CUA_MARKING = 'SWITCH'
  1953.    endif
  1954.  compile endif
  1955. compile endif
  1956. compile if EVERSION < 5
  1957.    call init_operation_on_commandline()
  1958. compile endif
  1959.    oldcol=.col
  1960.    if matchtab_on and .line>1 $NOT_CMD_STATE then
  1961.       up
  1962.       c=.col
  1963.       tab_word
  1964.       if oldcol>=.col then
  1965.          .col=oldcol
  1966.          tab
  1967.       endif
  1968.       down
  1969.    else
  1970.       tab
  1971.    endif
  1972. compile if WANT_STREAM_MODE | WANT_TAB_INSERTION_TO_SPACE
  1973.  compile if WANT_STREAM_MODE = 'SWITCH' and not WANT_TAB_INSERTION_TO_SPACE
  1974.    if insertstate() & stream_mode $NOT_CMD_STATE then
  1975.  compile else
  1976.    if insertstate() $NOT_CMD_STATE then
  1977.  compile endif
  1978.       numspc=.col-oldcol
  1979.       if numspc>0 then
  1980.          .col=oldcol
  1981.          keyin substr('',1,numspc)
  1982.       endif
  1983.    endif
  1984. compile endif
  1985. compile if EVERSION < 5
  1986.    call move_results_to_commandline()
  1987. compile endif
  1988. compile if TOGGLE_TAB
  1989.    endif
  1990. compile endif  -- TOGGLE_TAB
  1991.  
  1992.  
  1993. def up=
  1994. compile if TOP_OF_FILE_VALID = 'STREAM' & WANT_STREAM_MODE = 'SWITCH'
  1995.    universal stream_mode
  1996. compile endif
  1997. compile if WANT_CUA_MARKING
  1998.  compile if WANT_CUA_MARKING = 'SWITCH'
  1999.    universal CUA_marking_switch
  2000.    if CUA_marking_switch then
  2001.  compile endif
  2002.       unmark
  2003.  compile if WANT_CUA_MARKING = 'SWITCH'
  2004.    endif
  2005.  compile endif
  2006. compile endif
  2007. compile if WANT_STREAM_MODE
  2008.    call updownkey(0)
  2009. compile else
  2010.    up
  2011. compile endif
  2012. compile if TOP_OF_FILE_VALID = 'STREAM' & WANT_STREAM_MODE = 'SWITCH'
  2013.    if not .line & stream_mode then '+1'; endif
  2014. compile elseif not TOP_OF_FILE_VALID
  2015.    if not .line then '+1'; endif
  2016. compile endif
  2017.  
  2018. compile if WANT_CUA_MARKING & EPM
  2019. def s_up=
  2020.  compile if TOP_OF_FILE_VALID = 'STREAM' & WANT_STREAM_MODE = 'SWITCH'
  2021.    universal stream_mode
  2022.  compile endif
  2023.  compile if WANT_CUA_MARKING = 'SWITCH'
  2024.    universal CUA_marking_switch
  2025.  compile endif
  2026.    startline = .line; startcol = .col
  2027.  compile if WANT_STREAM_MODE
  2028.    call updownkey(0)
  2029.  compile else
  2030.    up
  2031.  compile endif
  2032. ;compile if WANT_CUA_MARKING = 'SWITCH'
  2033. ;  if CUA_marking_switch then
  2034. ;compile endif
  2035.    if .line then call extend_mark(startline, startcol, 0); endif
  2036. ;compile if WANT_CUA_MARKING = 'SWITCH'
  2037. ;  endif
  2038. ;compile endif
  2039.  compile if TOP_OF_FILE_VALID = 'STREAM' & WANT_STREAM_MODE = 'SWITCH'
  2040.    if not .line & stream_mode then '+1'; endif
  2041.  compile elseif not TOP_OF_FILE_VALID
  2042.    if not .line then '+1'; endif
  2043.  compile endif
  2044. compile endif
  2045.  
  2046. compile if EPM  -- Standard PM clipboard functions.
  2047. def s_del = 'cut'
  2048.  
  2049. def s_ins =
  2050.  compile if WANT_CUA_MARKING = 'SWITCH'
  2051.    universal CUA_marking_switch
  2052.    if CUA_marking_switch then
  2053.  compile endif
  2054.  compile if WANT_CUA_MARKING
  2055.       call process_mark_like_cua()
  2056.  compile endif
  2057.  compile if WANT_CUA_MARKING = 'SWITCH'
  2058.    endif
  2059.  compile endif
  2060.    'paste' DEFAULT_PASTE
  2061.  
  2062. def c_ins = 'copy2clip'
  2063. compile endif
  2064.  
  2065. compile if WANT_STREAM_MODE
  2066. defproc updownkey(down_flag)
  2067.    universal save_cursor_column
  2068.  compile if WANT_STREAM_MODE = 'SWITCH'
  2069.    universal stream_mode
  2070.    if stream_mode then
  2071.  compile endif
  2072.       lk = lastkey(1)
  2073.  compile if EPM
  2074.       updn = pos(leftstr(lk,1),\x18\x16) & pos(substr(lk,2,1),\x02\x0A\x12)   -- VK_DOWN or VK_UP, plain or Shift or Ctrl
  2075.  compile else
  2076.       updn = substr(lk,1,1)=\0 & pos(substr(lk,2,1),\x48\x50\x98\xA0\x8d\x91) -- Up, down, a_up, a_down, c_up, c_down
  2077.  compile endif
  2078.       if not updn then save_cursor_column = .col; endif
  2079.  compile if WANT_STREAM_MODE = 'SWITCH'
  2080.    endif
  2081.  compile endif
  2082.  
  2083.    if down_flag then down else up endif
  2084.  
  2085.  compile if WANT_STREAM_MODE = 'SWITCH'
  2086.    if .line & stream_mode then
  2087.  compile else
  2088.    if .line then
  2089.  compile endif
  2090.       l = length(textline(.line))
  2091.       if updn & l>=save_cursor_column then
  2092.          .col = save_cursor_column
  2093.       elseif updn | l<.col then
  2094.          end_line
  2095.       endif
  2096.    endif
  2097. compile endif  -- WANT_STREAM_MODE
  2098.  
  2099. /* ------ Keys unused in standard E ------------------------------------------
  2100.  
  2101. a_2, a_3, a_5, a_6, a_7, a_8, a_9
  2102.  
  2103. a_f2, a_f3, a_f4, a_f5, a_f6, a_f9
  2104.  
  2105. a_g, a_h, a_i, a_k, a_q, a_v
  2106.  
  2107. c_6, c_minus, c_backslash
  2108.  
  2109. c_leftbracket, c_rightbracket, (EOS2 only:) a_leftbracket, a_rightbracket
  2110.  
  2111. c_f9, c_f10
  2112.  
  2113. c_g, c_i, c_j, c_prtsc, c_q, c_u
  2114.  
  2115. f5
  2116.  
  2117. s_f6, s_f7, s_f8, s_f9, s_f10
  2118.  
  2119. -----  The following is for EOS2 4.10 or above only.  -----
  2120.  
  2121. New keys that work on even older unenhanced AT keyboards:
  2122.    c_up, c_down
  2123.    pad5, c_pad5
  2124.    c_padminus, c_padplus, c_padstar
  2125.    c_ins, c_del
  2126.    c_tab, a_tab
  2127.    a_leftbracket, a_rightbracket
  2128.  
  2129. On an enhanced keyboard only:
  2130.    f11, f12, and c_,s_,a_
  2131.    pad_enter               is defined the same as enter
  2132.    a_enter and a_padenter are defined the same as enter
  2133.    c_pad_enter             is defined the same as c_enter
  2134.    pad_slash               is defined the same as '/'
  2135.    c_padslash              is defined the same as '/'
  2136.  
  2137. -----  The following is for EPM only.  -----
  2138.   * Since we are using only keys defined by PM (and not looking at
  2139.     scan codes), we no longer have the keys:
  2140.       padplus, c_padplus, c_padstar
  2141.       pad_slash, c_padslash
  2142.       pad5, c_pad5
  2143.    * We gained the new keys:
  2144.     - space, s_space, c_space, and a_space
  2145.          (The space bar is a virtual key to PM, not a character key.  If you
  2146.          want to bind an action to the space key, write  def space=  instead of
  2147.          the old  def ' '= .  The good news is that you get all the shift
  2148.          states of the space bar, although alt_space is preempted by PM.)
  2149.     - c_1 through c_0
  2150.          (So now we have a complete set of alt- and ctrl-digits.)
  2151. ---------------------------------------------------------------------------- */
  2152.  
  2153.