\ SED.SEQ Top SED entry point for the Z editor by Tom Zimmer handle sedhndl : set.file ( | --- f1 ) \ setup file name in ed1hndl >in @ >r bl word dup c@ 0<> \ input not empty swap 1+ c@ '/' <> and \ and not starting with '/' if r>drop here sedhndl $>handle sedhndl handle>ext 1+ \ check EXTs for type dup " SCR" caps-comp 0= \ SCREEN or over " BLK" caps-comp 0= or \ BLOCK then if blockfile_on \ no CRLFs then dup " TXT" caps-comp 0= \ TEXT or swap " SEQ" caps-comp 0= or \ SEQUENTIAL then if blockfile_off \ normal text file then true else r> >in ! " UNTITLED" ">$ sedhndl $>handle true then ; : ?settext ( -- ) >in @ >r bl word 1+ " /text" caps-comp 0= here 1+ " /txt" caps-comp 0= or here 1+ " /file" caps-comp 0= or here 1+ " /seq" caps-comp 0= or if r>drop blockfile_off else r> >in ! then ; : ?setscreen ( -- ) >in @ >r bl word 1+ " /scr" caps-comp 0= here 1+ " /blk" caps-comp 0= or if r>drop blockfile_on bl word number? nip if 255 min !> oblen else drop then else r> >in ! then ; ?browse 0= #if : ?setbrowse ( --- ) >in @ >r bl word 1+ " /blk" caps-comp \ NOT /blk here 1+ " /b" caps-comp 0= and \ but other /b's \ look for /Bxxxx to set start line if on> ?browse r> 2+ >in ! bl word number? 2drop !> read-from else r> >in ! then ; #else : ?setbrowse ( -- ) on> ?browse ; #then : ?goto_line ( --- ) >in @ >r bl word number? 0= if 2drop r> >in ! exit then drop 20000 umin 0max dup =: loadline LAST.TEXTLINE 3 / min 1 max !> scrline r>drop >in @ >r bl word number? 0= if 2drop r> >in ! exit then drop 1- 131 min 0 max =: screenchar r>drop ; : ?ex_cmd ( -- ) \ do we want to exit with a command byte? ?cmd ?exit off> ?cmd >in @ >r bl word 1+ @ dup $432F ( /C ) = \ /CMD or /C or /cmd or /c swap $632F ( /c ) = or if on> ?cmd \ enable command mode decr> last.textline \ save a line for messages off> rmset? \ no word wrap bl word c@ if msghndl clr-hcb \ preclear handle here 1+ c@ '\' = \ starts with '\'? here 3 + c@ '\' = or \ or with drive '\'? 0= \ NOT! if seqhandle count seqhandle >pathend" nip - msghndl place then here count msghndl +place else seqhandle msghndl $>handle then get_MSG_file \ read the message file process_msgs \ process the message file r>drop exit then r> >in ! ; comment: SED may be OPTIONALLY followed by a filename and a line number and column to start editing in the form: SED JUNKFILE 100 33 This starts up SED on the file JUNKFILE at line 100, column 33. comment; : sed ( | --- ) on> seding edinit decimal read_cfg off> read-from \ clear read from line backingup =: renaming off> loadline first.textline =: scrline set.file ( --- f1 ) if ?<>bak tsegb #edsegs + =: tend off> newfl sedhndl $file \ opens the file. if on> newfl set.newfile sinit on> edready then begin >in @ \ current input offset ?setbrowse \ /B{xxxx} ?goto_line \ {line} {column} ?ex_cmd \ /cmd {filename} ?settext \ /text or /txt ?setscreen \ /scr or /blk >in @ = \ repeat until no change until OFF> newfl then done ; : exit_display ( -- ) >norm dark 25 2 at ." \1 Tom's Sequential Editor " 5 spaces ." \0 Dated: " cdate 2@ form-date count type space ctime 2@ drop dtbuf off build-hm dtbuf count type 0 5 at ." \s04The \3 NEWZ \0 editor is Copyright 1989-1994 by Tom Zimmer" ." \n\n\s08\3 NEWZ \0 is distributed as shareware." ." \n\n\s08If you like NEWZ and use it regularly, please support" ." \n\s08the shareware concept by registering your copy of NEWZ." ." \n\s08Send a donation for $60.00 to the address below and you" ." \n\s08will receive the latest version of NEWZ.\n" ." \n\s11Tom Zimmer" ." \n\s11292 Falcato Drive" ." \n\s11Milpitas, California" ." \n\s11U.S.A. Zip 95035 home (408) 263-8859" ." \n\s35work (415) 327-8800\n" 7 attrib c! 0 rows 2 - 2dup at cols spaces cr cols spaces at ; : cmdsesc ( -- ) ?cmd \ if in command mode and ?noprompt or hdepth 0= and \ file stack empty, leave now if Q_cmd sescall else sesc then ; : cmdsescall ( -- ) Q_cmd sescall ; : cmdsqut ( -- ) ?cmd \ if in command mode and ?noprompt or hdepth 0= and \ file stack empty, leave now if Q_cmd squtALL else Q_cmd squt then ; 196 fnset cmdsesc \ F10 save and exit 221 fnset cmdsescall \ Shift F10 exit all edit/browses 241 fnset cmdsqut \ Alt F10 discard edit and quit 216 fnset doerrs \ Shift F5 222 fnset cmd1 \ Control F1 223 fnset cmd2 \ Control F2 224 fnset cmd3 \ Control F3 225 fnset cmd4 \ Control F4 226 fnset cmd5 \ Control F5 \ 227 fnset sloow \ Control F6 search word under cursor 228 fnset cmd7 \ Control F7 229 fnset cmd8 \ Control F8 230 fnset cmd9 \ Control F9 231 fnset cmd10 \ Control F10