\ EDITSTUF.SEQ Stuff needed by the editor by Tom Zimmer only forth also definitions vocabulary editor only forth also hidden definitions also variable tsegb \ text segment beginning for current file variable lseg \ linelist save segment variable dseg \ delete lines segment variable toff variable tend variable lastline \ last valid line in file. variable warncnt \ warning count, if not enough memory for delete seg \ then tell user so, but only the first time. variable byte|line \ flag to tell if we are going to a line in file \ or a byte offset in file. variable edready \ ready to edit, we have a file, and can enter \ editor on it, with no problem. variable renaming \ are we keeping backup files? renaming on variable backingup variable currentsize \ size of the current file on disk in \ 128 byte sectors. : seginit ( --- ) defers initstuff 0 currentsize ! tsegb off lseg off dseg off ; ' seginit is initstuff 132 constant mxlln 4000 constant maxlines 100 constant maxdline 65000. 2constant maxD.filesize 0 constant screenchar \ A pseudo variable 0 constant curline \ A pseudo variable : memabort ( n1 --- ) 8 = abort" Could not allocate memory for Editor" ; : tbuf.init ( --- ) \ Allocate the edit buffers. toff off tend off tsegb @ 0= if 65536. 16 um/mod nip alloc memabort nip tsegb ! \ edit buffer 64k then lseg @ 0= if maxlines 2* 16 / 1+ alloc memabort nip lseg ! \ Line pointer table then dseg @ 0= warncnt @ 0= and if maxdline mxlln * 16 / 1+ alloc 8 = if dseg off cr >rev ." Memory Limited, LINE UNDELETE will NOT be available! " >norm beep 1 seconds beep 1 seconds warncnt incr else nip dseg ! \ delete buffer then then ; : edinit ( --- ) \ defers initstuff \ Add this to initialization list? tbuf.init ; \ Allocate the editor \ space needed. \ ' edinit is initstuff only forth also definitions hidden also : nobackup ( --- ) backingup off ; ' nobackup alias backupoff : backupon ( --- ) backingup on ; backupon \ default to auto backup of data : setbackup ( --- ) defers installstuff cr ." ******" backupon cr ." The editor can be configured to automatically create backup files" cr ." of your edits, this is more secure than not having backup files," cr ." but requires more disk space. If you are using a FLOPPY based " cr ." system, you MAY not want backup files created for you." cr ." Do you want the editor to automatically create backup files?" cr cr ." Press N for NO, any other key for YES ->" key bl or ascii n = if nobackup then cr cr tab ." F-PC " >rev ." WILL " backingup @ 0= if ." NOT " then >norm ." create backup files." ; ' setbackup is installstuff only forth also definitions