home *** CD-ROM | disk | FTP | other *** search
- \ WFL.SEQ Window file selection. by Tom Zimmer
-
- ONLY FORTH ALSO HIDDEN DEFINITIONS ALSO
-
- create rootdir ascii . c, 0 c, \ root is . & null
-
- 14 constant b/fnam \ bytes per filename
-
- : maxdir sp@ 100 - here 300 + - b/fnam / abs ;
-
- 5 constant forg \ top of file window display
- 15 constant dlen \ directory window length
- 16 constant dirattrib \ directory file attribute
-
- variable #fls \ number of files present
- variable curfl \ current file number
- variable foff
-
- : >fadr ( n1 --- a1 )
- b/fnam * ( first ) here 300 + + 1+ ;
-
- : .nam ( n1 --- )
- >fadr dup count swap over type
- 12 swap - spaces 1- c@ dirattrib and
- if #out @ 1- #line @ at
- ." ∞"
- then ;
-
- create excludes ," COMEXEARCBAKBINDRVMAPOBJBLKOVR"
-
- variable exlist excludes exlist !
- variable exsrc
-
- : ?exclude ( --- f1 ) \ f1 = true if in exclude list
- pad 30 + dup 12 over + swap
- do i c@ ascii . =
- if drop i 1+ leave
- then
- loop exsrc !
- 0 exlist @ ?dup 0= if exit then \ Leave if exlist=0
- count over + swap
- ?do i exsrc @ 3 comp 0= or
- 3 +loop ;
-
- : name>buf ( --- ) \ move name from dta to buffer
- #fls @ >fadr >r
- pad 30 + 12 dup 0
- do over i + c@ 0=
- if drop i leave
- then
- loop dup r@ c! r@ 1+ swap cmove
- pad 21 + c@ r> 1- c! ;
-
- : $getdir ( a1 --- )
- shndl+ $>handle \ get directory spec
- curfl off foff off #fls off
- pad SET-DTA
- shndl+ >nam findfirst
- begin 255 and 0= #fls @ maxdir > 0= and
- while ?exclude 0=
- if name>buf #fls incr
- then findnext
- repeat ;
-
- : getdir ( --- )
- " *.*" ">$ $getdir ;
-
- : -ss 0 do 196 emit loop ;
-
- : -ll ( l r len line --- )
- 17 swap forg + at rot emit -ss emit ;
-
- : showdrives ( --- )
- 218 191 57 12 -ll 17 forg 13 + at 179 emit
- ." Press - A B C D E F G H I - to select a disk drive. "
- 2 spaces 179 emit 192 217 57 14 -ll ;
-
- : showret ( --- )
- 17 forg 4 + at 179 emit
- space 17 emit 196 emit 217 emit
- ." = Select file/directory " 179 emit
- 17 forg 5 + at 179 emit
- ." Esc = Cancel file selection " 179 emit
- 17 forg 6 + at 179 emit
- ." Del = Delete a file " 179 emit
- 17 forg 7 + at 179 emit
- ." \ = Type a new path name " 179 emit
- 192 217 29 8 -ll ;
-
- : showkeys ( --- ) \ show some help
- 218 191 16 -1 -ll
- 17 forg at " Hom x PgUp " >r
- 179 over c! 179 over 6 + c! 24 over 8 + c!
- 179 over 10 + c! 179 over 17 + c! r> type
- 17 forg 1+ at 179 emit space 4 -ss 197 emit
- 3 -ss 197 emit 5 -ss space 179 emit
- 17 forg 2+ at " End x PgDn " >r
- 179 over c! 179 over 6 + c! 25 over 8 + c!
- 179 over 10 + c! 179 over 17 + c! r> type
- ( 192 217 ) 195 193 16 3 -ll 12 -SS 191 EMIT
- showret showdrives ;
-
- : pathbox ( --- )
- 218 191 57 9 -ll 17 forg 10 + at 179 emit
- ." Path = " 0 25 bdos 65 + emit ." :\"
- 46 spaces 179 emit 192 217 57 11 -ll ;
-
- : showpath ( --- )
- pathbox 28 forg 10 + at pad 64 erase
- pad 0 pdos 0=
- if ." \" pad 64 over + swap
- do i c@ ?dup if emit else leave then
- loop
- else ." Can't read path"
- then ;
-
- : showdir ( --- ) \ display cirectory window
- #out @ #line @ >r >r 1 forg 1- at
- 218 emit 14 0 do 196 emit loop 191 emit dlen 0
- do 1 i forg + at i foff @ + #fls @ >= 179 emit
- if i 0= if ." ...No Files..."
- else b/fnam spaces then
- else curfl @ i foff @ + =
- if ( 221 ) 16 emit
- i foff @ + .nam
- ( 222 ) 17 emit
- else space i foff @ + .nam space
- then
- then 179 emit
- loop 1 forg dlen + at 192 emit 14 0 do 196 emit loop
- 217 emit r> r> at ;
-
- : nfl ( --- ) \ next file
- curfl @ #fls @ 1- 0 max = if exit then
- curfl @ 1+ #fls @ 1- min 0 max dup curfl !
- dup #fls @ < swap dlen 1- - foff @ = and
- if foff @ 1+ #fls @ 15 - 0 max min foff !
- then ;
-
- : pfl ( --- ) \ previous file
- curfl @ 1- 0 max dup curfl !
- foff @ =
- if foff @ 1- 0 max foff !
- then ;
-
- : 0fl ( --- ) \ first file
- curfl off foff off ;
-
- : efl ( --- )
- begin nfl curfl @ #fls @ 1- 0 max = until ;
-
- : delfl ( --- )
- curfl @ >fadr dup >r 1- c@ dirattrib and
- 19 forg 10 + 2dup at 55 spaces at
- if ." Can't delete directory !" beep 1 seconds
- else ." Delete '" r@ count type ." ' <- Y/N [N] "
- cursor-on key cursor-off bl or ascii y =
- if sequp
- r@ shndl @ $>handle
- shndl @ hdelete 5 =
- if ." Access denied !"
- beep 1 seconds
- then seqdown
- then curfl @ foff @ getdir
- foff ! curfl !
- then r> drop showpath ;
-
- : ndir ( --- )
- begin cursor-on pathbox ascii \ pad c!
- 29 forg 10 + at pad 1+ 50 expect
- span @ pad 1+ + off
- pad 59 bdos
- while ." <- Invalid Path" beep 1 seconds
- repeat cursor-off getdir showpath 0fl ;
-
- : ndriv ( n1 --- n1 )
- dup bl or 97 - 0 max select
- getdir showpath 0fl ;
-
- : keytests ( n1 --- )
- dup false = if ( do nothing ) else
- ( up arrow ) dup 200 = over 56 = or if pfl else
- ( down arrow ) dup 208 = over 50 = or if nfl else
- ( PgUp ) dup 201 = over 57 = or if dlen 1- 0 do pfl loop else
- ( PgDn ) dup 209 = over 51 = or if dlen 1- 0 do nfl loop else
- ( \ ) dup 92 = if ndir else
- ( A to I ) dup bl or ascii a ascii i between
- if ndriv else
- ( Del ) dup 211 = over 46 = or if delfl else
- ( Home ) dup 199 = over 55 = or if 0fl else
- ( End ) dup 207 = over 49 = or if efl else beep
- then then then then then then then then then then drop ;
-
- : ?setdir ( c1 --- c2 f1 ) \ return bool false if new dir
- curfl @ >fadr dup >r 1- c@ dirattrib and
- if drop
- r@ count swap pad 2 pick cmove
- pad + off pad @ rootdir @ =
- if ascii \ pad c!
- then pad 59 bdos drop
- cursor-off getdir showpath 0fl
- false false
- else true
- then r> drop ;
-
- ONLY FORTH DEFINITIONS ALSO HIDDEN ALSO
-
- : <getfile> ( --- <a1> f1 ) \ return a1 filename addr and
- #out @ #line @ >r >r savescr cursor-off getdir
- 0fl showkeys showpath
- begin showdir 0 0 at
- key dup 13 = dup
- if drop ?setdir ( c1 --- c2 f1 )
- then over 27 = or 0=
- while keytests
- repeat 13 = dup
- if curfl @ >fadr dup c@ 1+ pad >r r@
- swap cmove r> swap
- then r> r> at
- restscr cursor-on
- #fls @ 0<> and ;
-
- ' <getfile> is getfile \ patch in window get file.
-