home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
f88
/
view.bak
< prev
Wrap
Text File
|
1988-06-07
|
9KB
|
248 lines
\ VIEW.SEQ Viewing code for ZF. by Tom Zimmer
mbuf.init \ buffer in ram for a screen
variable viewlen
: >VIEWLINE ( n1 --- ) \ move to line n1 of currently open file.
dup >r 0 shndl @ movepointer
ibreset errorline off
r> loadline ! ;
: <viewlines> ( n1 n2 --- )
loadline @ >r viewlen off
swap 0
do lineread dup c@ 0= if drop leave then
cr count 2- 0 max
i 3 pick =
if >attrib2 type >norm \ underline it.
else type 77 #out @ - spaces
then outbuf c@ viewlen +!
loop drop cr r> loadline ! ;
: VIEWLINES ( n1 n2 --- ) \ n1 lines to view, n2 line to underline.
>attrib4 shndl @ count type >norm <viewlines> ;
: NAME>PAD ( A1 --- PAD )
>r r@ ys: ?cs: pad r> yc@ 31 and 1+ cmovel \ move name
pad c@ 31 and pad c! \ clip count
pad count + 1- dup c@ 127 and swap c! \ mask last ch
PAD ;
: ?prepend.vpath ( a1 --- a1 )
>r r@ 3 + c@ ascii \ = \ ? already have path
if r> exit then \ then leave
r@ count viewpath count + swap cmove
r@ c@ viewpath c@ + \ total length
dup r@ c! \ to a1
viewpath 1+ r@ 1+ rot cmove \ move data to a1
viewpath count + off \ erase extra viewpath
r> ; \ return a1
comment:
: >viewfile ( cfa --- offset a1 ) \ returns the string name in PAD
filelist \ of the file containing cfa as a1
begin @ 2dup u> until \ step to proper file name.
SWAP >view y@ \ Also returns offset to source def.
SWAP BODY> >NAME name>pad ?prepend.vpath ;
comment;
: files_set ( --- )
['] files >body HERE 500 + #THREADS 2* CMOVE ;
: 1file ( --- false | nfa )
HERE 500 + #THREADS LARGEST DUP
if DUP L>NAME >r Y@ SWAP ! r>
else nip
then ;
0 constant maxname
0 constant maxcfa
: >viewfile ( cfa --- offset a1 )
>r files_set 0 =: maxcfa 0 =: maxname
begin 1file dup
while r@ over name> u>
if dup name> maxcfa u>
if dup =: maxname
dup name> =: maxcfa
then
then drop
repeat drop r> >view y@
maxname name>pad ?prepend.vpath ;
: <VIEW> ( a1 --- f1 ) \ VIEW the name specified by a1 the cfa
>viewfile ( --- offset f1 )
$hopen dup 0=
if swap CLS 0 1 at \ dark cr
>viewline 21 0 viewlines \ show 21 (was 17) lines from file.
else nip
then ;
variable foundit
: <HELP> ( a1 --- f1 ) \ Show the HELP for a word specified by a1
>viewfile >r drop
" HLP" ">$ r@ $>ext
r> $hopen dup 0=
if ibreset 0.0 seek loadline off
." Looking..." foundit off
8000 1
do lineread c@ 0= ?leave
bl outbuf count + 2- c!
\ have at least 1 blank at end of line.
here count outbuf 1+ swap 1+ caps-comp 0=
if dark cr ." Line " i u. ." of "
loadline @ >viewline 21 0 viewlines
foundit on leave
then outbuf c@ loadline +!
loop foundit @ 0=
if ." ..Sorry, no information available"
then cr
then ;
: .VIEWHELP ( --- )
cursor-off dark
mbuf.prep
>attrib4 0 2 at ." HELP ME GET STARTED! " >norm
0 4 at
." To obtain help on a particular word, type: HELP <wordname> <enter>"
0 5 at
." To see the source code for a word, type: VIEW <wordname> <enter>"
0 6 at
." To find out what commands are available, type: WORDS <enter>"
0 7 at
." (space pauses, ESC stops list)"
0 8 at
." To find out which words contain a"
0 9 at
." particular letter sequence, type: WORDS <letters> <enter>"
0 10 at
." To see a decompiled source for a word, type: SEE <wordname> <enter>"
0 11 at
." To open a file, use VIEW above, or type: OPEN <filename> <enter>"
0 12 at
." To edit the currently open file, type: ED <enter>"
0 13 at
." (press ESC to leave the editor)"
0 14 at
." To create a file, or select a file to edit, type: SED <enter>"
0 16 at
." Type the following command sequence for a couple of examples:"
11 18 at >attrib1 ." OPEN INTRO <enter>"
11 19 at ." L <enter>" >norm
0 21 at
." See the accompanying .TXT files for further descriptions of FF."
movem mbuf.off
0 22 at cursor-on ;
comment:
\ This is how paging works. Copy this word to a small test file.
: testview
savescr cls
page2 .viewhelp 2 >page
60 tillkey
page0 restscr 0 >page ;
comment;
: VIEW ( | name --- ) \ VIEW is followed on the same line by name.
>in @ span @ 1- > \ if nothing following command
if .viewhelp \ display the help screen
else ' <view>
if cr ." File " .file ." is not available."
then
then ;
' view alias LL ( | name --- ) \ LL is a pseudonym for VIEW
: HELP ( | name --- ) \ VIEW is followed on the same line by name.
>in @ span @ 1- > \ if nothing following command
if .viewhelp \ display the help screen
else ' <help>
if cr ." File " .file ." is not available."
then
then ;
: ?fileopen ( --- ) \ Verify a file is open.
shndl @ >hndle @ 0<
abort" A file MUST be open to perform this operation." ;
: L ( --- ) \ display (18) lines starting at current
?fileopen
dark cr \ loadline marker.
loadline @ >viewline
21 -1 viewlines ;
: LIST ( n1 --- ) \ n1 is the line number to list from
?fileopen
>line L ;
: LOAD ( n1 --- ) \ n1 is the line number to load from
?fileopen
>line \ move to line n1
cr ." Loading.." <load> ;
: +lines ( n1 --- ) \ move forward n1 lines in the current file.
loadline @ >viewline
0 swap 0
?do lineread c@ + outbuf c@ 0= ?leave
loop loadline +! ;
: N ( --- ) \ go forward 16 lines and display 18 lines.
?fileopen
16 +lines L ;
: -1line ( --- ) \ backup 1 line from current loadline
loadline @ dup 0> swap 256 - swap
if 0 max
then 0 shndl @ movepointer
IBRESET INSTART
256 loadline @ dup 0>
if min else drop then
shndl @ INBSEG EXHREAD =: inlength
inlength INSTART over 2- 0 max bounds swap
?do INBSEG i c@L 10 = \ is char an LF
if drop INSTART inlength + i 1+ -
leave
then
-1 +loop negate loadline +! ;
: -lines ( n1 --- ) \ backup n1 lines in the current file.
0
?do -1line
loop ;
: B ( --- ) \ backup 16 lines in current file and
?fileopen
16 -lines L ; \ display 18 lines.
\ installation routine, added to the list of stuff to do when installing
\ FF for a new system.
: setview ( | name --- ) \ set the path for all views
>in @ span @ 1- > \ if nothing following command
if viewpath clr-hcb
viewpath prepend.path drop
cr ." ******"
cr ." The current PATH where F88 searches for system sources when viewing is"
cr cr tab >rev viewpath count type >norm cr
cr ." Type in the New VIEW PATH (where the system sources are located),"
cr ." or press <enter> alone to leave the VIEW PATH the same. "
cr ." VIEW PATH ->"
query
then
>in @ span @ 1- > 0=
if viewpath clr-hcb
bl word viewpath over c@ 1+ cmove
then cr cr tab
." VIEW PATH set to " >rev viewpath count type >norm ;
: installviewpath ( --- )
defers installstuff
span @ >in !
setview ;
' installviewpath is installstuff