home *** CD-ROM | disk | FTP | other *** search
- \ PRINTING.SEQ Export & Import for SED. by 1987 Tom Zimmer
-
- only forth also hidden also editor also definitions
-
- variable dolst dolst off
-
- : p$type ( a1 --- ) \ print string at address
- count over + swap
- ?do i c@ pemit
- loop ;
-
- : pcr ( --- ) 13 pemit 10 pemit #out off ;
-
- : ptype ( a1 n1 --- ) bounds
- ?do i c@ pemit
- loop ;
-
- : .p## ( N1 --- ) \ Print two low digits of n1.
- 0 <# # # #> pTYPE ;
-
- : <.pTIME> BASE @ >R DECIMAL SWAP 0 256 UM/MOD .p## " :" ptype .p##
- " :" ptype 0 256 UM/MOD .p## drop
- \ " ." ptype .p##
- R> BASE ! ;
-
- : <.pDATE> ( D1 --- )
- BASE @ >R DECIMAL
- 0 256 UM/MOD .p## " /" ptype .p## " /" ptype 1900 - .p##
- R> BASE ! blnks 3 ptype ;
-
- : pdate/time GETDATE <.pdate> gettime <.ptime> ;
-
- variable controlines \ number of control line encountered.
-
- : skipto ( a1 --- a2 ) \ skips all but one leading bl
- 1+
- begin dup c@ bl =
- while 1+
- repeat 1- ;
-
- : ?escprint ( --- f1 )
- linebuf 1+ dup c@ ascii . =
- swap 1+ c@ ascii # = and dup
- if linebuf 3 + controlines incr
- begin skipto dup 1+ c@
- ascii 0 ascii 9 between
- while 0.0 rot convert nip swap
- 255 min pemit
- repeat drop
- then ;
-
- : .noprinter ( --- )
- dolst @ 0=
- if 0 statusline at blnks 18 type
- else cr
- then " *** Printer OFF LINE, or NOT connected. ***"
- type eeol beep
- dolst @ 0=
- if showcur 2 seconds emptykbd scrshow then ;
-
- : printline ( --- ) ?escprint ?exit
- blnks lmargin @ ptype
- stripbl's linebuf count ptype
- pcr getline ;
-
- variable pagenumber 1 pagenumber !
- variable firstpage 1 firstpage !
- variable lastpage 99 lastpage !
-
- : .underline ( --- ) \ underline current line.
- 13 pemit #out off
- 78 0
- do ascii _ pemit
- loop pcr pcr ;
-
- : .pg# ( --- )
- pagenumber @
- if .underline
- " Page " ptype
- pagenumber @ 0 <# #s #> ptype " of " ptype
- pagenumber incr
- lastpage @ 0 <# #s #> ptype " Pages" ptype
- blnks 10 ptype
- pdate/time
- blnks 78 shndl @ c@ - #out @ - ptype
- shndl @ p$type
- then ;
-
- : newpage ( --- )
- formfeed pemit ;
-
- : setpage firstpage @ pagenumber ! ;
-
- : linesleft ( --- ) \ lines left to print on page
- curline controlines @ 1- 0 max - 0 max
- prtlines mod ;
-
- : .header ( --- ) \ print first line of the current file
- pcr pcr
- 0 #lineinfo ?cs: pad rot dup >r cmovel
- blnks lmargin @ ptype pad r> ptype
- .underline ;
-
- : ?newpage ( --- )
- linesleft 0=
- if .pg# newpage .header
- then ;
-
- variable copies 1 copies !
-
- variable pgtoprint 1 pgtoprint !
-
- : todocpage ( --- )
- pgtoprint @ 1- 0 max 199 min prtlines *
- to.line first.textline =: screenline
- dolst @ 0=
- if scrshow
- then ;
-
- variable lsttoprint 99 lsttoprint !
-
- : ?lastppg ( --- f1 )
- lsttoprint @ 199 min prtlines * 2-
- curline < ;
-
- : setlastpg ( --- )
- lastline @ prtlines /mod swap
- if 1+ then dup lsttoprint ! lastpage ! ;
-
- : doprint ( --- )
- ?printer.ready 0= if .noprinter exit then
- copies @ 0
- ?do <shom> dolst @ 0=
- if scrshow
- then .header
- todocpage setpage controlines off
- begin curline 0=
- if pcr
- else printline then
- ?lastline 0= key? 0= and
- ?lastppg 0= and
- while dolst @ 0=
- if dnln
- else <sdln>
- then ?newpage
- repeat prtlines linesleft - 1- 0 max
- 0 ?do pcr loop
- .pg# newpage key? ?leave
- loop <shom> dolst @ 0=
- if scrshow emptykbd
- then ;
-
- : insertsector ( --- f1 ) \ f1=true if end of file
- 0 temp2.buf 128 over + swap
- do i c@ 26 = i c@ 0= or
- if drop true leave then
- i c@ dup 10 <> \ ignore LnFeed
- if dup 13 = \ <CR> ins Line
- if drop nln
- else schr \ insert char
- then
- else drop then
- loop ;
-
- : imp/exp.init ( --- )
- " TEMP.SEQ" ">$ shndl+ $>handle ;
-
- : getinpfile ( --- f1 )
- imp/exp.init
- ?shiftkey dup >rev
- if drop
- ." Select File from window to Import...Esc to Cancel"
- eeol >norm
- ['] qemit is emit getfile 0= showstat
- ['] (emit) is emit if true exit then
- shndl+ $>handle false
- else ." Importing from " shndl+ count type
- eeol >norm 3 tenths \ a small delay
- then ;
-
-
- : ?getexpfile ( --- f1 )
- imp/exp.init
- ?shiftkey dup
- if drop " Export Filename -->"
- first.textline inputline !
- input$ dup c@ 0= escflg @ or 0=
- if shndl+ $>handle shndl+ pathset
- " Can't read path" ?terror true
- else drop false
- then 0= scrshow
- then ;
-
- : export ( --- )
- markline @ dup 0< swap curline > or
- if beep exit
- then ?getexpfile ?exit
- 0 statusline at ." Copying text..." eeol
- sdln \ move down a line in file
- shndl+ dup >r hcreate 0=
- if 0.0 r@ movepointer
- temp.buf 10 26 fill
- ?cs: temp.buf curline 1- #lineinfo + 10 cmovel
- markline @ #lineinfo drop nip
- curline 1- #lineinfo + nip over - 1+ \ +1 = ^Z
- r@ tsegb @ exhwrite drop
- r@ hclose drop ." ..Done "
- else ." Failed " beep 1 seconds
- then r> drop eeol suln 2 tenths ;
-
- ' export is exportx \ patch into smaller editor
-
- : excut ( --- ) \ Cut out marked text
- markline @ dup 0< swap curline > or
- if beep exit
- then ?getexpfile ?exit
- 0 statusline at ." Cutting text..." eeol
- sdln \ move down a line in file
- shndl+ dup >r hcreate 0=
- if 0.0 r@ movepointer
- temp.buf 10 26 fill
- ?cs: temp.buf curline 1- #lineinfo + 10 cmovel
- markline @ #lineinfo drop nip
- curline 1- #lineinfo + nip over - 1+ \ +1 = ^Z
- r@ tsegb @ exhwrite drop
- r@ hclose drop ." ..Done "
- curline markline @ - 0 max 0 2dup >
- if markline @ backto.line
- ?do <ldel> \ Delete current line
- loop scrshow
- else 2drop
- then
- else ." Failed " beep 2 seconds
- then r> drop eeol suln sdln 2 tenths ;
-
- ' excut is excutx \ patch into smaller editor
-
- : import ( --- )
- 0 statusline at ." Inserting text..." eeol 2 tenths
- getinpfile ?exit
- imode dup @ >r on
- shndl+ dup >r hopen 0=
- if 0.0 r@ movepointer
- begin temp2.buf 128 r@ hread 128 <
- insertsector or showstat
- key? if key 27 = or then
- until r@ hclose drop
- then r> drop
- r> imode ! emptykbd ;
-
- ' import is importx \ patch into smaller editor
-
- defer escattrib ' >rev is escattrib
-
- : torev ['] >rev is escattrib ;
- : toblnk ['] >revblnk is escattrib ;
-
- 5 constant pitems
-
- create prtmenu pitems c,
- 28 , 8 , ," First Page to print" pgtoprint ,
- 28 , 10 , ," Last Page to print" lsttoprint ,
- 28 , 12 , ," Left margin indent" lmargin ,
- 65 , 8 , ," Start numbering pages at" firstpage ,
- 65 , 10 , ," Copies to print" copies ,
-
- : showpdata ( --- )
- >rev prtmenu count 0
- do dup 2@ swap at
- 4 + count + dup @ @ 5 .l 2+
- loop drop >norm ;
-
- : showcmds ( --- )
- 14 16 at >bold ." Press " escattrib
- ." ESC " >bold ." to cancel, or " escattrib
- ." P " >bold ." to start printing" >norm ;
-
- : showpform ( --- ) dark
- 25 1 at >rev ." Printing Setup Menu " >norm
- 15 3 at >bold ." Use Enter or Arrows to move between fields"
- 22 5 at ." Use + or - to change values" >norm
- prtmenu count 0
- do dup 2@ 2 pick 4 + c@ - 1- swap at
- 4 + count 2dup type + 2+
- loop drop 64 7 at ." 0=no #'s" showcmds ;
-
- : sc ( --- )
- torev showcmds ;
-
- variable pitem variable pnumval
-
- : >pitem ( --- a1 )
- prtmenu 1+ pitem @ 0
- ?do 4 + count + 2+
- loop ;
-
- : showpcur ( --- )
- >pitem 2@ 6 + swap at ;
-
- : ptohome pitem off pnumval off torev showpcur ;
-
- : penter ( c1 --- c1 ) dup 13 = \ Enter key
- over 208 = or \ down arrow
- if pitem @ 1+ pitems mod pitem ! sc
- showpcur pnumval off drop 0
- then ;
-
- : pincr ( c1 --- c1 ) dup 43 = \ plus "+" sign
- if >pitem 4 + count + @
- pitem @ pitems 1- =
- if dup @ 0= swap !
- else incr
- then showpdata sc showpcur drop 0
- then ;
-
- : pdecr ( c1 --- c1 )
- dup 45 = \ minus "-" sign
- if >pitem 4 + count + @
- dup @ 1- 0 max swap !
- showpdata sc showpcur drop 0
- then ;
-
- : prright ( c1 --- c1 )
- dup 203 = \ left arrow
- over 205 = or \ right arrow
- if pitem @ 3 + pitems mod pitem ! sc
- showpcur pnumval off drop 0
- then ;
-
- : prup ( c1 --- c1 )
- dup 200 = \ up arrow
- if pitem @ 5 + pitems mod pitem ! sc
- showpcur pnumval off drop 0
- then ;
-
- : pbkspace ( c1 --- c1 )
- dup 8 = \ back space
- if pnumval off
- >pitem 4 + count + @ off
- showpdata sc showpcur drop 0
- then ;
-
- : pnum ( c1 --- c1 ) \ number between 0 and 9
- dup ascii 0 >= over ascii 9 <= and
- if dup ascii 0 - pnumval @ 10 * + 199 min
- dup pnumval ! >pitem 4 + count + @ !
- showpdata sc showpcur drop 0
- then ;
-
- : pmenu ( --- ) \ print menu
- setlastpg
- showpform showpdata ptohome
- begin key dup 27 <> over
- ( Alt-P ) 153 <> and over bl or
- ascii p <> and
- while penter pincr pdecr pnum pbkspace
- prright prup
- if toblnk showcmds torev beep showpcur
- then
- repeat showscreen bl or ascii p =
- if doprint then ;
-
- ' pmenu is pmenux
-
- \ IDS printer initialization, sets printer for
- \ black & while printer ribbon.
-
- : elisting ( --- )
- [ editor ]
- read.openfile
- sinit setlastpg
- cr ." Printing..."
- #out @ #line @ >r >r
- dolst on doprint dolst off
- r> r> at ;
-
- only forth definitions
-
-