home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
MOUSEDIR.ZIP
/
MOUSEDIR.KML
< prev
next >
Wrap
Text File
|
1992-03-27
|
9KB
|
299 lines
* For KEDIT 5.x and OS/2 2.x only!
*
* The following must be in your path:
*
* REXXUTIL.DLL REXXREF2.KEX KILLDIR.KEX
*
* Following are mouse macros for navigating directories with DIR
* Make sure the following block of lines is in your PROFILE.KEX file:
*
*-----------------------------------------------------------------------------------------------------------*
* 'define mousedir.kml' *
* status = statusline.1() statusline.2()
* if fext.1() = 'DIR' then do
* 'set statusline off'
* 'set prefix off'
* 'set mousetext user [Help] [MDir] [Copy] [Erase] [Tag] [Sort] [Refresh] [..] [QQ]'
* l = line.1()
* ':1'
* 'set reserved 1 Directory: ' dirfileid.2() || dirfileid.3()
* ':'l
* end
* else do
* 'set mousetext user [Help] [Move] [Copy] [Delete] [Undo] [RxFmt] [Dir] [Save] [Quit]'
* 'set statusline on bottom'
* 'set prefix on left'
* end
*-----------------------------------------------------------------------------------------------------------*
*
:BUTTON1DOWN
* If this is a dir file, just tag/untag the line
* tag line If shift key isn't down
'extract /click'
If DIR() Then Do
'set highlight tag'
l = LINE.1()
'cursor screen' click.2 click.3
If ^mouseposmodifiable() Then Exit
':'LINE.1()
If LINEFLAG.3() = 'NOTAG' Then 'set lineflag tag'
Else 'set lineflag notag'
':'l
'cursor cmdline'
End
'macro buttonxdown stream'
:BUTTON1DBLCLK
* All modifications commented below.
If ^mouseposmodifiable() Then Do
'sos mousebeep'
Exit
End
If DIR() Then Do
If DIRFILEID.1() == '' Then
'sos mousebeep'
Else If POS('<dir>',CURLINE.3()) = 0 Then Do
* Modified to UNZIP *.ZIP files while in DIR
* UNZIP.KEX Must be in path
If TRANSLATE(DIRFILEID.5()) = 'ZIP' Then 'UNZIP' DIRFILEID.1()
* If extension is ICO, fire up ICON editor.
Else If TRANSLATE(DIRFILEID.5()) = 'ICO' Then 'DOSNOWAIT ICONEDIT' DIRFILEID.1()
Else 'kedit' DIRFILEID.1() '(nodefext'
'Set statusline on bottom'
End
Else Do
'extract /dirfileid'
'dir' dirfileid.1
l = LINE.1()
':1'
'extract /dirfileid'
':'l
* Always show directory info on top line
'Set reserved 1 Directory: ' dirfileid.2 || dirfileid.3
'Set statusline off'
End
Exit
End
If SHIFT() Then Do
'set drag word extend'
'mark word anchor'
End
Else Do
'set drag word replace'
'mark word anchor reset'
End
'set lineflag notag'
:MOUSEBAR_UNDO
* Allow for UNDO as a mousebar macro
'UNDO'
:MOUSEBAR_ERASE
* Erase tagged files and subdirectories
'macro tagged erase'
:MOUSEBAR_..
* Go to parent subdirectory.
If SIZE.1() = 0 Then Exit
If TOF.1() = 'ON' | EOF.1() = 'ON' Then ':0 1'
If DIRFILEID.3() = '\' Then 'emsg Already in root directory'
Else 'dir "'DIRFILEID.2() || DIRFILEID.3() || '\.."'
l = LINE.1()
':1'
'extract /dirfileid'
':'l
'Set reserved 1 Directory: ' dirfileid.2 || dirfileid.3
:MOUSEBAR_REFRESH
* Refresh the current DIR listing
'cursor cmdline'
l = LINE.1()
':1'
curdir = DIRFILEID.2() || DIRFILEID.3()
'dir' curdir
':'l
'Set reserved 1 Directory: ' curdir
:MOUSEBAR_SORT
* Put sort option on mouse bar
'set mousetext user Sort by: [Name] [Extension] [Date] [Size] [QuitSort]'
:MOUSEBAR_QUITSORT
* Reset mousebar to DIR text
'set mousetext user [Help] [MDir] [Copy] [Erase] [Tag] [Sort] [Refresh] [..] [QQ]'
:MOUSEBAR_DATE
* Sort by date
'dirsort date'
'set defsort date'
:MOUSEBAR_EXTENSION
* Sort by extension
'dirsort extension'
'set defsort extension'
:MOUSEBAR_NAME
* Sort by name
'dirsort name'
'set defsort name'
:MOUSEBAR_SIZE
* Sort by size
'dirsort size'
'set defsort size'
:MOUSEBAR_QQ
* Quit from DIR listing
'nomsg quit'
If NBFILE.1() = 0 Then Exit
If rc <> 0 Then 'dialog $'LASTMSG.1()'$ title $Quit$ alert'
'set statusline on bottom'
:MOUSEBAR_RXFMT
* Indent and format source. See REXXREF2.DOC
'macro rexxref2'
:MOUSEBAR_DIR
* Get DIR listing
'DIR'
:MOUSEBAR_TAG
* Tag/Untag all lines
l = LINE.1()
':1'
If LINEFLAG.3() = 'NOTAG' Then 'tag select 0'
Else 'TAG'
':'l
:MOUSEBAR_COPY
* If in DIR listing, copy tagged files to specified location
If \DIR() Then 'macro mousebar_block copy block'
Else 'macro tagged copy'
:TAGGED
* Get list of tagged lines
* Used by MOUSEBAR_ERASE and MOUSEBAR_COPY.
*
* tagged.x contains the DIRFILEID.1() of the xth tagged line.
* tagged_dir.x = 0 if xth line is a file, 1 if it's a subdir.
* tagged_line.x contains the line number of the xth tagged line.
* tagged.0 contains the number of tagged lines.
*
Arg task
If task = '' Then Do
'EMSG No task specified.'
Exit
End
'cursor cmdline'
curl = LINE.1()
t = 0
tagged_dir. = 0
Do i = 1 To SIZE.1()
':'i
If LINEFLAG.3() = 'TAG' Then Do
t = t + 1
tagged.t = DIRFILEID.1()
tagged_line.t = i
If POS('<dir>',CURLINE.3()) > 0 Then tagged_dir.t = 1
End
End
tagged.0 = t
':'curl
If tagged.0 = 0 Then Do
'EMSG No tagged files!'
Exit
End
* Now operate on tagged lines according to 'task'
*----------------------------------------------------------------------*
* ERASE: erase all tagged files and subdirectories. *
*----------------------------------------------------------------------*
If task = 'ERASE' Then Do
'DIALOG /ALL tagged files and subdirectories will be erased!!/OKCANCEL DEFBUTTON 2'
If dialog.2 <> 'OK' Then Exit
Do t = 1 To tagged.0
tagrc = 0
If tagged_dir.t = 1 Then Do
* Can't erase the subdir we started from without CHDIR.
If TRANSLATE(tagged.t) = DIRECTORY.1() Then 'chdir ..'
'macro killdir' tagged.t
tagrc = rc
End
Else 'ERASE' tagged.t
If tagrc = 0 Then Do
':'tagged_line.t
'OVERLAY _<_E_R_A_S_E_D_>_'
'set lineflag notag'
End
End
End
*----------------------------------------------------------------------*
* COPY or MOVE: Copy/move all tagged items to specified destination. *
*----------------------------------------------------------------------*
If task = 'COPY' Then Do /* Copy files */
'DIALOG /'task 'tagged items to what destination?/EDITFIELD'
If dialog.2 = 'CANCEL' Then Exit
If dialog.1 = '' Then Do
'EMSG No destination given for' task'!'
Exit
End
dest = TRANSLATE(dialog.1)
curdir = DIRECTORY.1()
msgmode = MSGMODE.1()
'set msgmode off'
'chdir' dest
chrc = rc
'chdir' curdir
'set msgmode' msgmode
If chrc <> 0 Then Do /* Nonexistent destination */
'sos beep'
'DIALOG /'dest 'does not exist' || D2C(13) || 'Create it?/YESNOCANCEL'
If dialog.2 <> 'YES' Then Exit
Else 'dosquiet md' dest
End
'MSG Copying tagged files to' dest'. Please wait. . .'
'REFRESH'
Do t = 1 To tagged.0
If tagged_dir.t = 1 Then Do
'EMSG COPY not valid for subdirectories.'
Iterate
End
Else Do
':'tagged_line.t
'dosquiet COPY' tagged.t dest '>nul'
'MSG' tagged.t 'copied to' dest
'set lineflag notag'
End
End
End
':'curl
:MOUSEBAR_MDIR
* Create new subdirectory
'cursor cmdline'
curl = LINE.1()
':'1
dest = DIRFILEID.2() || DIRFILEID.3()
curdir = DIRECTORY.1()
msgmode = MSGMODE.1()
Do Forever
'DIALOG /Type name of new subdirectory:/EDITFIELD/'dest'/'
If dialog.2 = 'CANCEL' | dialog.1 = '' Then Exit
dest = TRANSLATE(dialog.1)
'set msgmode off'
'chdir' dest
chrc = rc
'chdir' curdir
If chrc = 0 Then Do /* Already exists */
'set msgmode on'
'EMSG' dest 'already exists!'
Iterate
End
Else Leave
End
'dosquiet md' dest
'set msgmode' msgmode
':'curl
'macro mousebar_refresh'
'msg' dest 'created.'