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