mirror of
https://github.com/forth-ev/VolksForth.git
synced 2024-11-29 21:49:17 +00:00
1 line
13 KiB
Plaintext
1 line
13 KiB
Plaintext
\\ Printer Interface cas 11nov05 This File contains the Printer Interface definitions for M130i Printer. The definitions can be used to print Forth Sourcecode in a consice way 6 Screens per page. When using the Multitask-Extension it is possible to print and continue working with Forth. This Printerinterface is based on Ideas from D. Weineck and was portet to volksFORTH by U. Hoffmann and K.Schleisiek. \ Printer Interface M 130i cas 10nov05 Onlyforth Vocabulary Printer Printer definitions also Variable pcol pcol off Variable prow prow off Variable prints prints off 2 &10 thru cr .( Printer Interface for M130i loaded ) \ &11 load cr .( Spooler loaded ) : plist ( scr -- ) prints lock output push print 10cpi cr list cr 5 lf's prints unlock ; Onlyforth \ Printer controls ks 23 m<>r 88 | : ctrl: ( 8b --) Create c, Does> ( --) c@ lst! ; 07 ctrl: bell $7F | ctrl: ~bs $D | ctrl: ~cr $A ctrl: ~lf $C ctrl: ~ff $F | ctrl: (+17cpi $1B | ctrl: ESC $12 | ctrl: (-17cpi | : esc: ( 8b --) Create c, does> ( --) ESC c@ lst! ; | : ESC2 ( 8b0 8b1 --) #esc lst! lst! ; | : on: ( 8b --) Create c, does> ESC c@ lst! 1 lst! ; | : off: ( 8b --) Create c, does> ESC c@ lst! 0 lst! ; \ Printer Escapes ks 09 mai 88 Ascii 0 esc: 1/8" Ascii 1 esc: 1/10" Ascii 2 esc: 1/6" Ascii T esc: suoff Ascii N esc: jump Ascii O esc: -jump Ascii G esc: dark Ascii H esc: -dark Ascii 4 esc: cursive Ascii 5 esc: -cursive Ascii M esc: 12cpi Ascii P | esc: (-12cpi : 10cpi (-12cpi (-17cpi ; : 17cpi (-12cpi (+17cpi ; ' 10cpi Alias pica ' 12cpi Alias elite \ Printer Escapes ks 09 mai 88 Ascii W on: wide Ascii W off: -wide Ascii - on: +under Ascii - off: -under Ascii S on: sub Ascii S off: super Ascii p on: prop Ascii p off: -prop : lf's ( n -- ) 0 ?DO ~lf LOOP ; : lines ( #.of.lines -- ) Ascii C ESC2 ; : "long ( inches -- ) 0 lines lst! ; : american 0 Ascii R ESC2 ; : german 2 Ascii R ESC2 ; : normal 12cpi american suoff 1/6" &12 "long ~cr ; \ Printer Output ks 24 m<>r 88 cr .( verarbeitet Umlaute nicht richtig ) : pemit ( char -- ) $7F and 1 pcol +! dup BL u< IF $40 or +under lst! -under exit THEN lst! ; : pcr ~cr ~lf 1 prow +! pcol off ; : pdel ~bs pcol @ 1- 0 max pcol ! ; : ppage ~ff prow off pcol off ; : pat ( row col -- ) over prow @ < IF ppage THEN swap prow @ - 0 ?DO pcr LOOP dup pcol @ < IF ~cr pcol off THEN pcol @ - spaces ; : pat? ( -- row col ) prow @ pcol @ ; \ Printer output ks 24 m<>r 88 : +emit dup (emit pemit ; : +cr (cr pcr ; : +del (del pdel ; : +page (page ppage ; : +at 2dup (at pat ; | Output: >printer pemit pcr tipp pdel ppage pat pat? ; | Output: +printer +emit +cr tipp +del +page +at (at? ; Forth definitions : print >printer normal ; : +print +printer normal ; \ Variables and Setup ks cas 10nov05 Printer definitions $00 | Constant logo | Variable pageno | Create scr#s &14 allot \ enough room for 6 screens | : header ( -- ) normal 4 spaces dark ." Page " pageno @ 2 .r &13 spaces ." volksFORTH83 " 5 spaces file? -dark 1 pageno +! ~lf ; \ Print 2 screens across on a page ks 09 mai 88 | : pr ( scr# -- ) dup capacity 1- u> IF drop logo THEN 1 scr#s +! scr#s dup @ 2* + ! ; | : 2pr ( scr#1 scr#2 line# -- ) cr 17cpi dup 2 .r space c/l * >r pad $101 bl fill swap block r@ + pad c/l cmove block r> + pad c/l + 1+ c/l cmove pad $101 -trailing type ; | : 2scr ( scr#1 scr#2 -- ) cr cr normal &17 spaces wide dark over 4 .r &28 spaces dup 4 .r -wide -dark cr l/s 0 DO 2dup I 2pr LOOP 2drop ; | : pr-start ( --) scr#s off 1 pageno ! ; \ Printer 6 screens on a page ks 24 m<>r 88 | : pagepr header scr#s off scr#s 2+ 3 0 DO dup @ over 6 + @ 2scr 2+ LOOP drop page ; | : shadowpr header scr#s off scr#s 2+ 3 0 DO dup @ over 2+ @ 2scr 4 + LOOP drop page ; | : pr-flush ( -- f ) \ any screens left over? scr#s @ dup 0=exit 0<> BEGIN scr#s @ 5 < WHILE -1 pr REPEAT logo pr ; | Variable shadow | : full? ( -- f ) scr#s @ 6 = ; \ Printer 6 screens on a page ks 09 mai 88 Forth definitions : pthru ( first last -- ) [ Printer ] prints lock output push print pr-start 1+ swap ?DO I pr full? IF pagepr THEN LOOP pr-flush IF pagepr THEN prints unlock ; : document ( first last -- ) [ Printer ] isfile@ IF capacity 2/ shadow ! THEN prints lock output push print pr-start 1+ swap ?DO I pr I shadow @ + pr full? IF shadowpr THEN LOOP pr-flush IF shadowpr THEN prints unlock ; : listing 0 capacity 2/ 1- document ; \ Printerspool ks 30 apr 88 \needs Task \\ | Input: noinput 0 false drop 2drop ; noinput $100 $200 Task spooler keyboard : spool ( from to -- ) isfile@ spooler 3 pass isfile ! pthru stop ; |