( EDITOR.BLK - SOURCE SCREENS FOR FORTH83 EDITOR ) \ LOAD SCREEN FOR EDITOR TESTING ON F83 VISA EDITOR.TST NEED OW NEED V+ NEED .DATE VOCABULARY EDITOR IMMEDIATE ALSO EDITOR DEFINITIONS ALSO WINDOW ALSO 2 12 THRU 14 16 THRU only forth also definitions \ fast screen writing ALSO FORTH DEFINITIONS VARIABLE SCR-SEG $B800 SCR-SEG ! EDITOR DEFINITIONS VARIABLE SCREEN-LOC CODE (FAST-LIST) ( addr scr.addr attrib --) BX AX MOV BX POP SI DX MOV SI POP ES PUSH SCR-SEG #) ES MOV CLD 16 DO CX PUSH 64 DO AL LODS ES: AX 0 [BX] MOV BX INC BX INC LOOP CX POP 80 64 - 2* # BX ADD LOOP DX SI MOV ES POP BX POP NEXT END-CODE : FAST-LIST ( addr -- ) SCREEN-LOC @ [ WINDOW ] 'CURSOR? @ >R HIDE.CURSOR ATTRIB DSEG@ (FAST-LIST) R> ?CURSOR ; \ Keyboard constants 1/3/83 7 /5 /88VARIABLE insert? VARIABLE cursor ( 0 to 1023 ) VARIABLE curscrn ( not necessarily same as SCR ) VARIABLE ED-FILE : POSITION ( -- position to 'cursor' ) cursor @ C/L /MOD AT ; : .INSERT BOTTOM insert? @ IF 52 " {INSERT}" >BOTTOM ELSE 52 " {OVERSTRIKE}" >BOTTOM THEN 3 " {F1 is HELP}" >BOTTOM 35 " {SCREEN " >BOTTOM curscrn @ (.) TYPE>EDGE " }" TYPE>EDGE POSITION ; \ editor 5/24/88 ) 11/16/88: slow-list ( addr -- ) 0 0 at 16 0 do dup i 64 * + 64 type cr loop drop 0 0 at ; : RELIST CURSCRN @ BLOCK graphics? if slow-list else FAST-LIST then ; : REFRESH .INSERT RELIST ; ( editor ) : tocursor ( new.loc -- ) 0 MAX 1023 MIN CURSOR ! POSITION ; : +cursor ( n -- ) CURSOR @ + TOCURSOR ; : trunc ( n1 n2 -- n3 n3 = n1 truncated to next lower multiple of n2 ) TUCK / * ; : totab ( -- truncate cursor back to tab stop ) cursor @ 8 trunc tocursor ; \ GO.MOUSE 6 /21/88: MOUSE.ABS ( -- Xn Yn ) \ screen abs of mouse in char incs M.POSITION ega? if 14 else 8 then / swap 8 / swap ; : MOUSE.LOC ( -- xn yn ) \ position in this window MOUSE.ABS ULX DSEG@ NEGATE ULY DSEG@ NEGATE V+ ; : MY.WINDOW ( -- x0 y0 xn yn ) 0 0 WIDTH DSEG@ 1- HEIGHT DSEG@ 1- ( x0 y0 xn xy ) ; \ editor ) 2 /19/88 VARIABLE UPDATE? : LINE# ( -- curr.line# ) CURSOR @ 64 / ; : restline ( -- #char.right.cursor) 64 cursor @ OVER MOD - ; : restscrn ( -- #line.below.cursor) 15 LINE# - ; : block+ ( scr.addr -- memory.addr ) curscrn @ BLOCK + ; : cursoraddr ( -- mem.addr ) cursor @ block+ ; : storechar ( char -- ) DUP EMIT CURSORADDR C! UPDATE? ON 1 +CURSOR ; : (BL.LINE) ( n -- ) 64 * BLOCK+ 64 BLANK ; : B.PLACE BLOCK+ SWAP MOVE ; : DATE.STAMP @DATE 50 BLOCK+ 14 BL FILL (.) 56 B.PLACE " /" 58 B.PLACE (.) 59 B.PLACE " /" 61 B.PLACE (.) DROP 2+ 2 62 B.PLACE UPDATE? ON RELIST ; ( editor ) : insertbyte ( char -- ) >R restline cursoraddr 2DUP DUP 1+ ROT 1- MOVE UPDATE? ON R> OVER C! SWAP TYPE 1 +cursor ; : deletebyte restline ?DUP IF cursoraddr 2DUP DUP 1+ SWAP ROT 1- MOVE UPDATE? ON 2DUP + 1- BL SWAP C! SWAP TYPE POSITION THEN ; : putchar insert? @ IF INSERTBYTE ELSE STORECHAR THEN ; : TOGGLE.INSERT INSERT? @ NOT INSERT? ! .INSERT ; : BACK-FIND BEGIN CURSCRN @ BLOCK CURSOR @ + C@ BL = CURSOR @ 0= NOT AND WHILE -1 +CURSOR REPEAT 1 +CURSOR ; ( editor ) : insertline restscrn ?DUP IF 64 * cursor @ 64 trunc block+ DUP 64 + ROT MOVE UPDATE? ON LINE# (BL.LINE) RELIST THEN ; : deleteline restscrn ?DUP IF 64 * cursor @ 64 trunc block+ DUP 64 + SWAP ROT MOVE UPDATE? ON 15 (BL.LINE) RELIST THEN ; : del>EOS ( -- ) \ delete to end of screen cursoraddr 1024 cursor @ - BLANK UPDATE? ON RELIST ; : saveline cursor @ 64 trunc block+ PAD 50 + 64 MOVE ; : pasteline PAD 50 + cursor @ 64 trunc block+ 64 MOVE UPDATE? ON RELIST ; \ editor ) 6 /21/88: eraseline CURSORADDR RESTLINE BLANK RELIST UPDATE? ON POSITION ; : ?UPDATE UPDATE? @ IF 2 20 20 1 $7900 $7900 OW ." Update (Y)/N ? " BEGIN KEY UPC DUP ASCII Y = IF DROP UPDATE TRUE UPDATE? OFF ELSE ASCII N = IF UPDATE? OFF TRUE ELSE BELL EMIT FALSE THEN THEN UNTIL CLOSE THEN ; : GOSCREEN ?UPDATE curscrn @ + capacity mod curscrn ! REFRESH POSITION ; : RETURNLINE 64 CURSOR @ + 64 TRUNC TOCURSOR ; : ENDLINE RETURNLINE -1 +CURSOR BACK-FIND ; \ menu : print.menu [ WINDOW ] 3 3 35 14 $7900 $7900 OW ." F2 go to SHADOW" CR ." F3 copy line to buffer" cr ." F4 replace line from buffer" cr ." F5 date stamp right corner " cr ." F6 delete to end of screen" cr ." F7 insert blank line" cr ." F8 remove line" cr ." F9 delete to end of line" cr ." F10/ESC end editing" cr ." PgUp go to previous screen" cr ." PgDn go to next screen" cr ." Home go to start of screen" cr ." Ins toggle INSERT/OVERSTRIKE mode" cr ." End go to end of line" WWAIT ; \ editspecial - special keys from text editor ) : editspecial ( keyval -- ) CASE $0C0 ( DEL>EOSKEY) OF del>eos ENDOF $0C7 ( HOMEKEY ) OF 0 tocursor ENDOF $0CD ( RIGHTCURSOR) OF 1 +cursor ENDOF $0CB ( LEFTCURSOR) OF -1 +cursor ENDOF 008 ( BACKSPACEKEY) OF -1 +cursor deletebyte ENDOF $0C8 ( UPCURSOR) OF -64 +cursor ENDOF $0D0 ( DOWNCURSOR ) OF 64 +cursor ENDOF $009 ( TABKEY ) OF 8 +cursor totab ENDOF $08F ( BACKTABKEY) OF -1 +cursor totab ENDOF $00D ( RETURNKEY ) OF RETURNLINE ENDOF $0BC ( SHADOWKEY) OF CAPACITY 2/ goscreen ENDOF $0BD ( CUT ) OF saveline ENDOF $0BE ( PASTE) OF pasteline ENDOF $0CF ( END ) OF ENDLINE ENDOF --> \ EDIT SPECIAL 5 /24/88$0D2 ( INSERTKEY) OF toggle.insert ENDOF $0D3 ( DELETEKEY) OF deletebyte ENDOF $0C1 ( INSLINE) OF insertline ENDOF $0C2 ( DELLINE) OF deleteline ENDOF $0D1 ( NEXTKEY) OF 1 goscreen ENDOF $0C9 ( PREVKEY) OF -1 goscreen ENDOF $0C3 ( ERASEKEY) OF eraseline ENDOF $0BB ( F1 ) OF PRINT.MENU ENDOF $0BF ( F5 ) OF DATE.STAMP ENDOF ENDCASE ; \ ED editor mainline 1/26/83 6 /21/88DEFER ED-INIT ' NOOP IS ED-INIT ONLY FORTH DEFINITIONS EDITOR ALSO FORTH : (ED) ( scr# cur.pos -- ) REOPEN >R FILE @ ED-FILE ! PAUSE 8 6 64 16 $600 $1900 OW [ ALSO WINDOW ] NOSCROLL IBM-AT? 80 * + 2* SCREEN-LOC ! curscrn ! insert? ON TOGGLE.INSERT ( ED-INIT ) REFRESH r> tocursor ED-INIT BEGIN KEY DUP $0C4 ( CANCELKEY) = OVER 27 ( ESC) = OR NOT WHILE DUP 32 127 WITHIN IF putchar ELSE editspecial THEN REPEAT ?UPDATE DROP CLOSE FLUSH REOPEN ; \ ED editor mainline 1/26/83 G06feb86geb: ED ( scr# -- ) 1 ?ENOUGH CAPACITY 1- MIN 0 (ED) ; : RED ( -- ) \ re-edit ED-FILE @ ?DUP IF [ DOS ] >FILE THEN curscrn @ CURSOR @ (ED) ; : ED: (VIEW) ED ; VARIABLE ERR-SCR VARIABLE ERR-CHAR : E-WHERE ERR-CHAR ! ERR-SCR ! ; ' E-WHERE IS WHERE : EED ( -- ) ERR-CHAR @ ERR-SCR @ DUP 0= IF 2DROP ." No error or Error at keyboard " ELSE (ED) THEN ; \ error edit \ FIND WORD PROGRAM EDITOR DEFINITIONS FORTH : ?IN-LINE ( addr -- f ) FALSE SWAP 64 'WORD C@ - BOUNDS DO I 'WORD COUNT CAPS-COMP 0= IF DROP TRUE LEAVE THEN LOOP ; : ?IN-BLOCK ( blk# -- ) BLOCK 1024 BOUNDS DO I ?IN-LINE IF CR I 64 -trailing type CR THEN 64 +LOOP ; ONLY FORTH DEFINITIONS EDITOR ALSO FORTH : FIND: ( from.scr to.scr -- ) \ FIND: TEXT; 2 ?ENOUGH ASCII ; WORD DROP CR ." BLK# " 1+ SWAP DO I . I ?IN-BLOCK START/STOP LOOP ; \ LOAD SCREEN FOR EDITOR TESTING ON F83 EDITOR.TST this file name OW open window V+ adds two 16bits to to other 16 bits (D+ with no carry) .DATE print system date EDITOR editor vocabulary load the screens \ fast screen writing 2 /18/1988BASE-SCREEN location of CGA screen SCREEN-LOC where on the screen does the block display (FAST-LIST) ( addr scr.addr attrib --) a code routine to list the screen very fast on a CGA monitor FAST-LIST ( addr -- ) setup for (FAST-LIST) \ Keyboard constants 1/3/83 2 /18/1988insert? insert/overstrike flag (insert=true) cursor 0 to 1023 location of cursor in screen curscrn current screen being edited ED-FILE current file being edited POSITION move actual cursor to where cursor var says it is .INSERT update insert/overstrike mode on the bottom of the editing window ( editor 12/27/83 ) 2 /18/1988RELIST redisplay the entire screen REFRESH redraw the border and RELIST ( editor ) 2 /18/1988tocursor ( new.loc -- ) move the cursor +cursor ( n -- ) move the cursor by an offset trunc ( n1 n2 -- n3 n3 = n1 truncated to next lower multiple of n2 ) totab truncate cursor back to tab stop \ GO.MOUSE 2 /18/1988INSIDE? ( x0 y0 xn yn x? x? -- f ) given window and x,y is x,y inside the window GO.MOUSE move cursor to mouse position \ editor ) 06feb86gebUPDATE? update flag checked on exiting screen LINE# return current line number restline how many characters are to the right of the cursor restscrn how many characters are after the cursor on the screen block+ ( scr.addr -- memory.addr ) cursoraddr ( -- mem.addr ) return memory addres of current cursstorechar overwrite a character (BL.LINE) ( n -- ) blank a line DATE.STAMP put a date stamp in the top right corner ( editor ) 2 /18/1988insertbyte ( char -- ) insert at cursor deletebyte delete at cursor moving in from right putchar depending on mode insert or overwrite character TOGGLE.INSERT change from insert<>overstrike BACK-FIND End key routine first go to the end of the line and then go backwards until you find a non-blank character ( editor ) 2 /18/1988insertline spread and insert a blank line ( bottom line is scrolled off screen ) deleteline delete a line del>EOS delete to end of screen saveline move a line to a one line buffer pasteline overwrite current line from the one line buffer \ editor ) 07FEB86GEBeraseline blank to end of line ?UPDATE ask user if updated screen should be saved GOSCREEN go to a screen number RETURNLINE editor cr/lf ENDLINE goto end of line \ menu 2 /18/1988print.menu help screen for editor \ editspecial - special keys from text editor ) 2 /18/1988editspecial ( keyval -- ) the editor case statement \ EDIT SPECIAL 2 /18/1988more editor case EDIT.MOUSE VERY simple mouse keys \ ED editor mainline 2 /18/1988 (ED) ( scr# cur.pos -- ) the main editor primitive \ ED editor mainline 2 /18/1988ED ( scr# -- ) user editor startup RED reedit at previous screen, changing file if necessary ED: edit the following already compiled definition ERR-SCR ERR-CHAR storage for screen and location of last error E-WHERE new WHERE routine that save screen and location EED edit at last error \ FIND WORD PROGRAM 2 /18/1988EDITOR DEFINITIONS FORTH ?IN-LINE ( addr -- f ) is the target on this line? ?IN-BLOCK ( blk# -- ) is the target in this block? FIND: ( from.scr to.scr -- ) \ FIND: TEXT; find the following text on the given screens