\ The Rest is Silence 2Oct83map 10dec84jap************************************************************* ************************************************************* *** *** *** Please direct all questions, comments, and *** *** miscellaneous personal abuse to: *** *** *** *** Joel Wittenberg KayPro adaption by *** *** 1315 Grove St #1 *** *** Berkeley, California *** *** 94709 *** *** *** *** (415) 524-1123 *** *** *** ************************************************************* ************************************************************* \ Visual editor load screen 09oct83jlwCAPS ON 1 11 +thru forth definitions exit \ visual < case, variables, and deferred words > 13oct83jlw: case ( item_count -- ) 1- constant does> 2dup @ 0 swap between not abort" out of range" swap 1+ 2* + perform ; editor definitions variable inserting inserting off variable altering altering off defer install defer back defer tab defer d_here defer n_line defer d_line defer i_line defer ret defer ins/ovr defer escape \ visual < at_up, _down, _fwd, _back, Cursor_Table > 13oct83jlw: at_Up ( -- ) line# if c/l negate r# +! then edit-at ; : at_Down ( -- ) line# 15 < if c/l r# +! then edit-at ; : at_Fwd ( -- ) cursor b/buf 1- < if 1 r# +! else beep then edit-at ; : at_Back ( -- ) cursor 0> if -1 r# +! else beep then edit-at ; 4 case Cursor_Table ] at_Up at_Down at_Fwd at_Back [ \ visual < vis_back, vis_char, over_char, ins_char > 11oct83jlw: vis_back (S char -- ) drop at_Back ; : vis_char ( adr cnt char -- adr cnt ) dup 'cursor c! emit modified ; : over_char ( adr cnt char -- adr cnt ) vis_char cursor b/buf 1- < if 1 r# +! then edit-at ; : ins_char ( adr cnt char -- adr cnt ) 'cursor dup 1+ #after 1- cmove> over_char 'cursor #after >type edit-at ; \ visual < tab_core, ins_tab, ovr_tab, vis_alt > 11oct83jlw: tab_core ( char -- cnt ) drop 4 col# 4 mod - b/buf 1- cursor - min ; : move_tab ( char -- ) tab_core r# +! edit-at ; : ins_tab ( char -- ) tab_core 0 ?do bl ins_char loop ; : ovr_tab ( char -- ) tab_core 0 ?do bl over_char loop ; : vis_alt ( char -- ) drop a .all edit-at ; \ visual < (insert), newline, ?altered > 13oct83jlw: (insert) ( adr cnt char -- adr cnt ) ['] ins_char is char ['] ins_tab is tab ; : (over_write) ( adr cnt char -- adr cnt ) ['] over_char is char ['] ovr_tab is tab ; : newline (S char -- ) drop line# 15 < if #after r# +! else 0 t then edit-at ; : ?altered (S -- ) changed @ if stamp save-buffers changed off then ; \ visual < d_left, d_here > 13oct83jlw: d_left (S char -- ) drop col# 0> if 'cursor dup 1- #after cmove modified bl 'cursor #after 1- + c! -1 r# +! edit-at 'cursor #after >type edit-at else beep then ; : del_here (S char -- ) drop col# c/l < if 'cursor dup 1+ swap #after 1- cmove bl 'cursor #after 1- + c! modified 'cursor #after >type edit-at else beep then ; \ visual < d_line, i_line, tab_usage > 13oct83jlw: del_line (S char -- ) drop x 16 line# do [ forth ] I [ editor ] redisplay loop edit-at ; : ins_line (S char -- ) drop 'insert c/l blank 'insert c/l 'line #end insert 16 line# do [ forth ] I [ editor ] redisplay loop edit-at ; : tab_usage (S -- ) altering @ if inserting @ if ['] ins_tab else ['] ovr_tab then else ['] move_tab then is tab ; \ visual < xxx_escape, xxx_install, xxx > 13oct83jlw: heath_escape (S escape -- ) drop key ascii A - Cursor_Table ; : heath_install 27 emit ." x6" ; : heath (S -- ) heath ['] heath_escape is escape ['] heath_install is install ; : ansi_escape (S char -- ) drop key ascii [ = if key ascii A - Cursor_Table then ; : ansi (S -- ) ansi ['] ansi_escape is escape ['] noop is install ; ansi \ visual < new_video, n_scr, p_scr, vis_edit_keys > 13oct83jlw: new_video (S -- ) 'start 'video b/buf cmove ; : n_scr ( char -- ) drop ?altered new_video n .all edit-at ; : p_scr ( char -- ) drop ?altered new_video b .all edit-at ; create vis_edit_keys ] CHAR VIS_ALT P_SCR RES-IN CHAR CHAR CHAR CHAR BACK TAB N_LINE D_HERE CHAR RET N_SCR CHAR P-IN CHAR CHAR CHAR CHAR BACK-UP INS/OVR I_LINE BACK-UP CHAR CHAR ESCAPE CHAR CHAR D_LINE CHAR [ \ visual < vis_cmd, vis_edit, (ret) > 13oct83jlw: vis_cmd (S -- ) ['] bs-in is back ['] cr-in is n_line ['] char is d_line ['] char is i_line ['] move_tab is tab ['] (DEL-IN) is DEL-IN ['] char is d_here ; : vis_edit (S -- ) ['] vis_back is back ['] newline is n_line ['] del_line is d_line ['] ins_line is i_line tab_usage ['] d_left is DEL-IN ['] del_here is d_here ; : (ret) ( max adr cnt char -- max adr max ) ['] (char) is char 50 0 at 9 spaces new_video altering off vis_cmd 0 23 at cr-in ; \ visual < (ins/ovr), visual, vedit, ved, done > 13oct83jlw: (ins/ovr) (S char -- ) drop altering on vis_edit 50 0 at inserting @ if ." replacing" (over_write) inserting off else ." inserting" (insert) inserting on then edit-at ; : visual (s -- ) vis_edit_keys CC ! ['] (ret) is ret ['] (ins/ovr) is ins/ovr install vis_edit ; forth definitions : VEDIT ( scr# -- ) [ EDITOR ] EDIT VISUAL ; : VED ( -- ) [ EDITOR ] ED VISUAL ; : DONE CC1 CC ! [ editor ] altering off DONE ; \ 13oct83jlw - Visual Mode Editor - invoke this editor by - scr# VEDIT ( edits scr# ) - VED ( edits current screen ) - a control key command list is on the next screen ^a - alternate between code and shadow screens 13oct83jlw^b - edit previous screen ^c - execute ABORT ^h - backspace ^i - tab ^j - newline ^k - delete current character ^m - ret ^n - edit next screen ^p - toggle printer switch ^u - cancel current comand line ^v - toggle between insert/replace mode (force one of them)^w - insert a blank line ^x - cancel current command line ^[ - parse escape sequence ^~ - kill current line (control tilde makes it hard to do)\ visual shadow screen #2 120ct83jlwCASE - case statement defining word. When used will create a constant with the child's name and maximum index. When the child is used it will either abort if the index is invalid or else it will index into the table and execute the desired function. INSERTING - True if in insert mode. ALTERING - True if in vis_edit mode. DEFER'D words need to be used before their definition and/or defined after their usage. \ visual shadow screen #3 13oct83jlwAT_XXXX - These four commands just move the cursor on the screen one position at a time, checking for screen boundarys as they go. UP and DOWN will not wrap, FORWARD and BACK will wrap until they reach the beginning or end of the screen. CURSOR_TABLE - create the cursor key case table. \ visual shadow screen #4 09oct83jlwVIS_BACK - Used in the command mode of the editor; it merely drops the character that invoked it and executes at_Back. VIS_CHAR - store the char in the block, echo it to the screen and mark the screen as changed. The basic visual edit function. OVER_CHAR - invoke VIS_CHAR and then if CURSOR will remain in bounds increment CURSOR and re-display the screen cursor. INS_CHAR - move all the characters on the current line that are not before CURSOR one position to the right then store the current char at CURSOR and re-display the changed part of the line. \ visual shadow screen #5 09oct83jlwTAB_CORE - calculate the column count to the next tab stop. MOVE_TAB - move the cursor to the next tab stop and re-display the cursor. INS_TAB - insert spaces until the next tab stop. OVR_TAB - over-write with spaces until the next tab stop. VIS_ALT - toggle to the shadow/image screen (alternate). \ visual shadow screen #6 09oct83jlw(INSERT) - install the CHAR and TAB vectors for inserting. (OVER_WRITE) - install the CHAR and TAB vectors for replacing. NEWLINE - move the cursor to the first column of the next line. Wrap to line# 0 if at line# 15. ?ALTERED - If the current screen is changed then stamp and save the screen and mark it as unchanged. \ visual shadow screen #7 13oct83jlwD_LEFT - delete the character to the left of the cursor (CURSOR -1), put a blank at the end of the line, decrement CURSOR, then redisplay the changed part of the line and reposition the terminal cursor. DEL_HERE - delete the character at the current cursor position (CURSOR), put a blank at the end of the line, then redisplay the changed part of the line and reposition the screen cursor. \ visual shadow screen #8 13oct83jlwD_LINE - delete the current line, move all remaining lines up one line, fill last line with blanks, redisplay the changed part of the screen and reposition the screen cursor. I_LINE - move the current line and all subsequent lines down one (dropping line 15), fill the current line with blanks, redisplay the changed part of the screen and reposition the screen cursor. TAB_USAGE - install the TAB vector according to the current usage ( move cursor, insert or replace with blanks). \ visual shadow screen #9 11oct83jlwXXXX_ESCAPE - interpret an escape sequence from the terminal; currently only used for cursor key interpretation. XXXX_INSTALL - terminal installation for visual editing. On the heathkit it sets the numeric pad to cursor keys. HEATH (ANSI, ETC) - install the terminal vectors according to the particular terminal desired. Note that since these terminal types were already defined inthe command mode section of the editor they are re-defined here to include the old definitions and add the visual mode controls. \ visual shadow screen #10 13oct83jlwNEW_VIDEO - overlay the video comparison buffer with the the current screen contents. Not really needed but it eliminates a useless screen re-display. N_SCR - Set the system ready to edit the previous screen. P_SCR - Set the system ready to edit the previous screen. VIS_EDIT_KEYS - the visual editing control key table. Used inside the editor instead of the normal forth control keys. \ visual shadow screen #11 11oct83jlwVIS_CMD - install the visual command mode control key vectors {BACK, N_LINE, D_LINE, I_LINE, TAB, DEL-IN, D_HERE}. VIS_EDIT - install the visual edit mode control key vectors {BACK, N_LINE, D_LINE, I_LINE, TAB, DEL-IN, D_HERE}. (RET) - install the standard forth CHAR vector, blank the "inserting"/"replacing" message, overlay the video compar- ision buffer, reset the editing flag, install the visual command mode control keys, move the cursor to the command line and perform a normal CR function. \ visual shadow screen #12 11oct83jlw(INS/OVR) - toggle between insert and replace mode, install the visual edit control keys, print the "replacing"/"inserting" message, install the CHAR vector with the correct routine, set the editing flag true and the inserting flag to agree with the CHAR vector, and position the cursor. VISUAL - replace the normal forth keys with the editing keys, install the RET and INS/OVR vectors and the visual control keys according to the editing flag. VEDIT - invoke the visual editor. VED - invoke the visual editor at the current screen. DONE - leave the visual editor.