home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / MOUSEDIR.ZIP / MOUSEDIR.KML < prev    next >
Text File  |  1992-03-27  |  9KB  |  299 lines

  1. * For KEDIT 5.x and OS/2 2.x only!
  2. *
  3. * The following must be in your path:
  4. *
  5. * REXXUTIL.DLL   REXXREF2.KEX  KILLDIR.KEX
  6. *
  7. * Following are mouse macros for navigating directories with DIR
  8. * Make sure the following block of lines is in your PROFILE.KEX file:
  9. *
  10. *-----------------------------------------------------------------------------------------------------------*
  11. * 'define mousedir.kml'                                                                                     *
  12. * status = statusline.1() statusline.2()
  13. * if fext.1() = 'DIR' then do
  14. *   'set statusline off'
  15. *   'set prefix off'
  16. *   'set mousetext user [Help] [MDir] [Copy] [Erase] [Tag]                    [Sort] [Refresh] [..] [QQ]'
  17. *   l = line.1()
  18. *   ':1'
  19. *   'set reserved 1 Directory: ' dirfileid.2() || dirfileid.3()
  20. *   ':'l
  21. * end
  22. * else do
  23. *   'set mousetext user [Help] [Move] [Copy] [Delete] [Undo] [RxFmt]     [Dir]             [Save] [Quit]'
  24. *   'set statusline on bottom'
  25. *   'set prefix on left'
  26. * end
  27. *-----------------------------------------------------------------------------------------------------------*
  28. *
  29. :BUTTON1DOWN
  30. * If this is a dir file, just tag/untag the line
  31. * tag line If shift key isn't down
  32.    'extract /click'
  33.    If DIR() Then Do
  34.       'set highlight tag'
  35.       l = LINE.1()
  36.       'cursor screen' click.2 click.3
  37.       If ^mouseposmodifiable() Then Exit
  38.       ':'LINE.1()
  39.       If LINEFLAG.3() = 'NOTAG' Then 'set lineflag tag'
  40.       Else 'set lineflag notag'
  41.       ':'l
  42.       'cursor cmdline'
  43.    End
  44.    'macro buttonxdown stream'
  45.  
  46. :BUTTON1DBLCLK
  47. * All modifications commented below.
  48.    If ^mouseposmodifiable() Then Do
  49.       'sos mousebeep'
  50.       Exit
  51.    End
  52.    If DIR() Then Do
  53.       If DIRFILEID.1() == '' Then
  54.         'sos mousebeep'
  55.       Else If POS('<dir>',CURLINE.3()) = 0 Then Do
  56. * Modified to UNZIP *.ZIP files while in DIR
  57. * UNZIP.KEX Must be in path
  58.          If TRANSLATE(DIRFILEID.5()) = 'ZIP' Then 'UNZIP' DIRFILEID.1()
  59. * If extension is ICO, fire up ICON editor.
  60.          Else If TRANSLATE(DIRFILEID.5()) = 'ICO' Then 'DOSNOWAIT ICONEDIT' DIRFILEID.1()
  61.          Else 'kedit' DIRFILEID.1() '(nodefext'
  62.          'Set statusline on bottom'
  63.       End
  64.       Else Do
  65.          'extract /dirfileid'
  66.          'dir' dirfileid.1
  67.          l = LINE.1()
  68.          ':1'
  69.          'extract /dirfileid'
  70.          ':'l
  71.          * Always show directory info on top line
  72.          'Set reserved 1 Directory: ' dirfileid.2 || dirfileid.3
  73.          'Set statusline off'
  74.       End
  75.       Exit
  76.    End
  77.    If SHIFT() Then Do
  78.       'set drag word extend'
  79.       'mark word anchor'
  80.    End
  81.    Else Do
  82.       'set drag word replace'
  83.       'mark word anchor reset'
  84.    End
  85.    'set lineflag notag'
  86.  
  87. :MOUSEBAR_UNDO
  88. * Allow for UNDO as a mousebar macro
  89.    'UNDO'
  90.  
  91. :MOUSEBAR_ERASE
  92. * Erase tagged files and subdirectories
  93.    'macro tagged erase'
  94.  
  95. :MOUSEBAR_..
  96. * Go to parent subdirectory.
  97.    If SIZE.1() = 0 Then Exit
  98.    If TOF.1() = 'ON' | EOF.1() = 'ON' Then ':0 1'
  99.    If DIRFILEID.3() = '\' Then 'emsg Already in root directory'
  100.    Else 'dir "'DIRFILEID.2() || DIRFILEID.3() || '\.."'
  101.    l = LINE.1()
  102.    ':1'
  103.    'extract /dirfileid'
  104.    ':'l
  105.    'Set reserved 1 Directory: ' dirfileid.2 || dirfileid.3
  106.  
  107. :MOUSEBAR_REFRESH
  108. * Refresh the current DIR listing
  109.    'cursor cmdline'
  110.    l = LINE.1()
  111.    ':1'
  112.    curdir = DIRFILEID.2() || DIRFILEID.3()
  113.    'dir' curdir
  114.    ':'l
  115.    'Set reserved 1 Directory: ' curdir
  116.  
  117. :MOUSEBAR_SORT
  118. * Put sort option on mouse bar
  119.    'set mousetext user Sort by:  [Name] [Extension] [Date] [Size]                   [QuitSort]'
  120.  
  121. :MOUSEBAR_QUITSORT
  122. * Reset mousebar to DIR text
  123.    'set mousetext user [Help] [MDir] [Copy] [Erase] [Tag]                    [Sort] [Refresh] [..] [QQ]'
  124.  
  125. :MOUSEBAR_DATE
  126. * Sort by date
  127.    'dirsort date'
  128.    'set defsort date'
  129.  
  130. :MOUSEBAR_EXTENSION
  131. * Sort by extension
  132.    'dirsort extension'
  133.    'set defsort extension'
  134.  
  135. :MOUSEBAR_NAME
  136. * Sort by name
  137.    'dirsort name'
  138.    'set defsort name'
  139.  
  140. :MOUSEBAR_SIZE
  141. * Sort by size
  142.    'dirsort size'
  143.    'set defsort size'
  144.  
  145. :MOUSEBAR_QQ
  146. * Quit from DIR listing
  147.    'nomsg quit'
  148.    If NBFILE.1() = 0 Then Exit
  149.    If rc <> 0 Then 'dialog $'LASTMSG.1()'$ title $Quit$ alert'
  150.    'set statusline on bottom'
  151.  
  152. :MOUSEBAR_RXFMT
  153. * Indent and format source.  See REXXREF2.DOC
  154.    'macro rexxref2'
  155.  
  156. :MOUSEBAR_DIR
  157. * Get DIR listing
  158.    'DIR'
  159.  
  160. :MOUSEBAR_TAG
  161. * Tag/Untag all lines
  162.    l = LINE.1()
  163.    ':1'
  164.    If LINEFLAG.3() = 'NOTAG' Then 'tag select 0'
  165.    Else 'TAG'
  166.    ':'l
  167.  
  168. :MOUSEBAR_COPY
  169. * If in DIR listing, copy tagged files to specified location
  170.    If \DIR() Then 'macro mousebar_block copy block'
  171.    Else 'macro tagged copy'
  172.  
  173. :TAGGED
  174. * Get list of tagged lines
  175. * Used by MOUSEBAR_ERASE and MOUSEBAR_COPY.
  176. *
  177. * tagged.x contains the DIRFILEID.1() of the xth tagged line.
  178. * tagged_dir.x = 0 if xth line is a file, 1 if it's a subdir.
  179. * tagged_line.x contains the line number of the xth tagged line.
  180. * tagged.0 contains the number of tagged lines.
  181. *
  182.    Arg task
  183.    If task = '' Then Do
  184.       'EMSG No task specified.'
  185.       Exit
  186.    End
  187.    'cursor cmdline'
  188.    curl = LINE.1()
  189.    t = 0
  190.    tagged_dir. = 0
  191.    Do i = 1 To SIZE.1()
  192.       ':'i
  193.       If LINEFLAG.3() = 'TAG' Then Do
  194.          t = t + 1
  195.          tagged.t = DIRFILEID.1()
  196.          tagged_line.t = i
  197.          If POS('<dir>',CURLINE.3()) > 0 Then tagged_dir.t = 1
  198.       End
  199.    End
  200.    tagged.0 = t
  201.    ':'curl
  202.    If tagged.0 = 0 Then Do
  203.       'EMSG No tagged files!'
  204.       Exit
  205.    End
  206. * Now operate on tagged lines according to 'task'
  207. *----------------------------------------------------------------------*
  208. * ERASE:  erase all tagged files and subdirectories.                   *
  209. *----------------------------------------------------------------------*
  210.    If task = 'ERASE' Then Do
  211.       'DIALOG /ALL tagged files and subdirectories will be erased!!/OKCANCEL DEFBUTTON 2'
  212.       If dialog.2 <> 'OK' Then Exit
  213.       Do t = 1 To tagged.0
  214.          tagrc = 0
  215.          If tagged_dir.t = 1 Then Do
  216.             * Can't erase the subdir we started from without CHDIR.
  217.             If TRANSLATE(tagged.t) = DIRECTORY.1() Then 'chdir ..'
  218.             'macro killdir' tagged.t
  219.             tagrc = rc
  220.          End
  221.          Else 'ERASE' tagged.t
  222.          If tagrc = 0 Then Do
  223.             ':'tagged_line.t
  224.             'OVERLAY                            _<_E_R_A_S_E_D_>_'
  225.             'set lineflag notag'
  226.          End
  227.       End
  228.    End
  229.  
  230. *----------------------------------------------------------------------*
  231. * COPY or MOVE: Copy/move all tagged items to specified destination.   *
  232. *----------------------------------------------------------------------*
  233.    If task = 'COPY' Then Do                              /* Copy files */
  234.       'DIALOG /'task 'tagged items to what destination?/EDITFIELD'
  235.       If dialog.2 = 'CANCEL' Then Exit
  236.       If dialog.1 = '' Then Do
  237.          'EMSG No destination given for' task'!'
  238.          Exit
  239.       End
  240.       dest = TRANSLATE(dialog.1)
  241.       curdir = DIRECTORY.1()
  242.       msgmode = MSGMODE.1()
  243.       'set msgmode off'
  244.       'chdir' dest
  245.       chrc = rc
  246.       'chdir' curdir
  247.       'set msgmode' msgmode
  248.       If chrc <> 0 Then Do                  /* Nonexistent destination */
  249.          'sos beep'
  250.          'DIALOG /'dest 'does not exist' || D2C(13) || 'Create it?/YESNOCANCEL'
  251.          If dialog.2 <> 'YES' Then Exit
  252.          Else 'dosquiet md' dest
  253.       End
  254.       'MSG Copying tagged files to' dest'.  Please wait. . .'
  255.       'REFRESH'
  256.       Do t = 1 To tagged.0
  257.          If tagged_dir.t = 1 Then Do
  258.             'EMSG COPY not valid for subdirectories.'
  259.             Iterate
  260.          End
  261.          Else Do
  262.             ':'tagged_line.t
  263.             'dosquiet COPY' tagged.t dest '>nul'
  264.             'MSG' tagged.t 'copied to' dest
  265.             'set lineflag notag'
  266.          End
  267.       End
  268.    End
  269.    ':'curl
  270.  
  271. :MOUSEBAR_MDIR
  272. * Create new subdirectory
  273.    'cursor cmdline'
  274.    curl = LINE.1()
  275.    ':'1
  276.    dest = DIRFILEID.2() || DIRFILEID.3()
  277.    curdir = DIRECTORY.1()
  278.    msgmode = MSGMODE.1()
  279.    Do Forever
  280.       'DIALOG /Type name of new subdirectory:/EDITFIELD/'dest'/'
  281.       If dialog.2 = 'CANCEL' | dialog.1 = '' Then Exit
  282.       dest = TRANSLATE(dialog.1)
  283.       'set msgmode off'
  284.       'chdir' dest
  285.       chrc = rc
  286.       'chdir' curdir
  287.       If chrc = 0 Then Do                            /* Already exists */
  288.          'set msgmode on'
  289.          'EMSG' dest 'already exists!'
  290.          Iterate
  291.       End
  292.       Else Leave
  293.    End
  294.    'dosquiet md' dest
  295.    'set msgmode' msgmode
  296.    ':'curl
  297.    'macro mousebar_refresh'
  298.    'msg' dest 'created.'
  299.