home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / COLEDIT.E < prev    next >
Text File  |  1992-08-26  |  3KB  |  104 lines

  1. /********************************/
  2. /* COLEDIT: Column Editing Mode */
  3. /********************************/
  4. /*
  5.  
  6. This is an EPM version of the Static Column Insert mode developed in E3
  7. PROCS by Russ Williams and Pat LaVarre.  It is implemented as a key set
  8. in EPM, which gives it more power.  The Column Editing mode is active
  9. even if the insert mode is not, so you have to assign a key (such as
  10. Ctrl + Ins) to toggle in and out of the mode.
  11.  
  12. The current "column" ends at the first occurrence of two spaces after
  13. the cursor.  Most editing functions only effect text within the current
  14. column.  The following keys will behave differently:
  15.    - characters typed in insert mode
  16.    - backspace
  17.    - del
  18.    - Ctrl + D (delete word)
  19. Note that F9 behaves as expected.
  20.  
  21. Column Editing does not work for block functions, Proof, and a few other
  22. miscellaneous things.
  23.  
  24. If you want to try it out just once without recompiling EPM, you can
  25. just use the EPM command:
  26.   relink coledit   (typed in the command box of EPM)
  27. This would enter the column edit mode immediately; use Ctrl + Ins to
  28. exit.
  29.  
  30. To make COLEDIT a normal part of EPM, you will need to create COLEDIT.EX
  31. by compiling COLEDIT.E:
  32.    ET COLEDIT  (typed in the command box of EPM)
  33. To incorporate it in your EPM, you need the following statement in
  34. MYKEYS.E or somewhere:
  35.   def c_ins = link 'coledit'
  36. Then EPM will have to be recompiled (ETPM EPM).
  37.  
  38. Problems & ideas:
  39.   - Delete & Backspace don't do anything if used in space at the
  40.     beginning of a line.
  41.   - Home & End could work inside the current column, or switch between
  42.     columns if already at the beginning or end of the current column.
  43.   - Maybe use line characters as column limits as well as double spaces.
  44.  
  45. Randy Bertram, RBERTRAM at LEXCJN1
  46.  
  47. */
  48.  
  49. compile if not defined( coledit_key )
  50.   const coledit_key ='c_ins'
  51. compile endif
  52.  
  53. definit
  54.    keys coledit_keys
  55.    if not insertstate() then
  56.       inserttoggle
  57.    endif
  58.    sayerror 'Column Editing Mode.'
  59.  
  60. defkeys coledit_keys
  61.  
  62. def $coledit_key =
  63.    sayerror 'Column Editing cancelled.'
  64.    keys edit_keys
  65.  
  66. def ''-'~', del, c_d, backspace, space=
  67.  
  68.    /* Get the line */
  69.    getline celine
  70.    protectcol = pos('  ',celine, .col)
  71.    if protectcol then
  72.       protectcol = verify(celine, ' ', , protectcol)
  73.    endif
  74.  
  75.    /* Do the key */
  76.    keys edit_keys
  77.    executekey lastkey()
  78.    keys coledit_keys
  79.  
  80.    /* Fix up the line if necessary */
  81.    getline newline
  82.    ceprefix = ''
  83.    cesuffix = ''
  84.    if length(newline) > length(celine) then
  85.       cesuffix = substr(' ',1,length(newline)-length(celine))
  86.    endif
  87.    if length(newline) < length(celine) then
  88.       ceprefix = substr(' ',1,length(celine)-length(newline))
  89.    endif
  90.    if protectcol > 0 and length(ceprefix || cesuffix) then
  91.       curcol = .col
  92.       .col = protectcol-length(ceprefix)
  93.       curins = insertstate()
  94.       if curins then
  95.          inserttoggle
  96.       endif
  97.       keyin ceprefix || substr(celine, protectcol) || cesuffix
  98.       if curins then
  99.          inserttoggle
  100.       endif
  101.       .col = curcol
  102.    endif
  103.  
  104.