home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / mlepm.zip / listmode.e < prev    next >
Text File  |  1994-05-24  |  4KB  |  131 lines

  1. /* listmode.e - this is the E part of the List mode package  940522 */
  2.  
  3. /* The space bar key has been defined to do specific List editing   */
  4. /* features.                                                        */
  5. /*                                                                  */
  6. /* [List means files like 00index.txt, or dir, or ...]              */
  7.  
  8. /* 940522: Martin Lafaix (lafaix@sophia.inria.fr)                   */
  9. /*                                                                  */
  10. /*  .A new function : List_mode.  It sets current editing mode to   */
  11. /*   be List mode.                                                  */
  12. /*                                                                  */
  13. /* 940521: Martin Lafaix (lafaix@sophia.inria.fr)                   */
  14. /*                                                                  */
  15. /*  .Adapting rexxmode.e to listmode.e.                             */
  16. /*                                                                  */
  17.  
  18. /* This file is an adaptation of the EPM 'rexxkeys.e' E Macro file  */
  19.  
  20. compile if not defined(BLACK)
  21. const
  22.    my_list_keys_is_external = 1
  23.    INCLUDING_FILE = 'LISTMODE.E'
  24.    EXTRA_EX = 0
  25.    WANT_CUA_MARKING = 'SWITCH'
  26.    include 'stdconst.e'
  27. compile else
  28.    const my_list_keys_is_external = 0
  29. compile endif
  30.  
  31. compile if INCLUDING_FILE <> 'EXTRA.E'  -- Following only gets defined in the base
  32.  
  33. definit
  34. compile if my_list_keys_is_external = 0
  35.    'maddhook load_hook list_load_hook'
  36. compile endif
  37.  
  38. defc List_mode
  39.    keys my_list_keys
  40.    'msetfilemode List mode'
  41.    'msetselectedsize 0'
  42.  
  43. defc list_load_hook
  44.    universal load_ext
  45.    universal load_var
  46.    if load_ext='LIST' | rightstr(upcase(.filename),11)='00INDEX.TXT' then
  47.       'List_mode'
  48.    endif
  49. compile endif
  50.  
  51. compile if WANT_CUA_MARKING & EPM
  52.  defkeys my_list_keys clear
  53. compile else
  54.  defkeys my_list_keys
  55. compile endif
  56.  
  57. def 'u', 'U'=
  58.    oldmod=.modify
  59.    'munhilitefile'
  60.    'msetselectedsize 0 *'
  61.    .modify=oldmod
  62.  
  63. def 'l', 'L'=
  64.    'mfindselected'
  65.  
  66. def space=
  67.    oldmod=.modify
  68.    call psave_mark(savemark)
  69.    unmark; mark_line
  70.    class=0; line=.line; col=1; off=-255
  71.    attribute_action 1, class, off, col, line
  72.    if class<>0 & line=.line then
  73.       'munhilitemark'
  74.       sign='-'
  75.    else
  76.       'process_style Selected'
  77.       sign='+'
  78.    endif
  79.    getline line
  80.    parse value line with wrd rest
  81.    do while wrd<>'' & verify(wrd,'0123456789')
  82.       parse value rest with wrd rest
  83.    enddo
  84.    if wrd='' then
  85.       size=0
  86.    else
  87.       size=wrd
  88.    endif
  89.    'msetselectedsize' size sign
  90.    call prestore_mark(savemark)
  91.    .modify=oldmod
  92.  
  93. defc mfindselected=
  94.    getfileid start_fid
  95.    'xcom e /c .selected'
  96.    .autosave=0
  97.    getfileid tools_fid
  98.    'mfind' start_fid tools_fid 'Selected'
  99.    .modify=0
  100.  
  101. defc mmoveselected
  102.    sayerror 'Not yet implemented... Sorry'
  103. compile endif  -- EXTRA
  104.  
  105. compile if not EXTRA_EX or INCLUDING_FILE = 'EXTRA.E'  -- Following gets defined in EXTRA.EX if it's being used
  106.  
  107. defc msetselectedsize
  108.    universal ML_array_ID
  109.    parse arg size sign
  110.    getfileid fileid
  111.    call get_array_value(ML_array_ID, fileid'.selected.size',  oldsize)
  112.    call get_array_value(ML_array_ID, fileid'.selected.count', oldcount)
  113.    if sign='+' then
  114.       oldsize = oldsize+size; oldcount=oldcount+1
  115.    elseif sign='-' then
  116.       oldsize = oldsize-size; oldcount=oldcount-1
  117.    else
  118.       oldsize=size; oldcount=0
  119.    endif
  120.    do_array 2, ML_array_ID, fileid'.selected.size', oldsize
  121.    do_array 2, Ml_array_ID, fileid'.selected.count', oldcount
  122.    if sign='+' | sign='-' | sign='*' then
  123.       if oldcount>1 then
  124.          'setstatusline Line %l of %s   'oldcount' Items selected ['oldsize' bytes] List mode     %m'
  125.       else
  126.          'setstatusline Line %l of %s   'oldcount' Item selected  ['oldsize' bytes] List mode     %m'
  127.       endif
  128.    endif
  129.  
  130. compile endif  -- EXTRA
  131.