various PETTIL design considerations
Posted: Thu Apr 24, 2014 5:04 am
The Apple II Applesoft BASIC editor had that horrid thing with like ESC D and you had to cursor to the end of the line before you hit return.
The TRS-80 Model I had something even worse, to wit:
EDLIN on the earliest MS-DOS machines was just awful. I can't remember what it was on CP/M (my Osborne 1 purchase for $7 at a garage sale in 1995 never saw much action, and I tended to play more with the Apple II and Apple III machines when I worked at ComputerLand in 1981)
During senior year of high school, 1979-1980, sometimes they would let me play on the Digital Equipment machine running TOPS-20 at Delta College in Saginaw. I actually liked TECO. The fastest I ever got with a code editor was on EDT on VAX/VMS circa late '80s. That thing was hooked up to the numeric keypad and it became second nature. Nowadays I use notepad clones (Geany) or vi, or rarely emacs.
But the Commodore 8-bits, they all have the coolest full screen editor! Also a graphics character set and lowercase. Move the cursor anywhere, hit return anywhere on the line and it parses the whole thing. A PET screen is exactly 1K consisting of 40x25 screen codes plus 24 bytes of 40/80 column "line wrap table". Rather than implement the Leo Brodie editor, I'm just going to marry Forth blocks to the Commodore screen editor. And today I got the STOP button to function as an ESC key. It isn't perfect yet, but I can tell it is going to work.
I'll stash piles of screens into a buffer that grows downward from the top of RAM until it bumps into the dictionary growing in the opposite direction. The entire buffer space will be stored in PRG files. That means it will work with a single magnetic storage device, either on cassette or disk. I'll bury the mass storage interface (just need "LOAD" and "SAVE" and maybe "VERIFY") inside the editor and I won't require FLUSH and SAVE-BUFFERS. BLOCK will merely uncompress one of the screens into a shadow video area ($7C00-7FFF). The lowest block number is 1. The highest block number is limited to how many buffers are currently in RAM. Attempting to access a block outside of that range will ABORT" BLOCK OUT OF RANGE"
The core of the editor is really simple. I hook the iRQ to trap the STOP key (my escape key) and dump out into a tight machine language loop to accept a line of text using the ROM editor, but don't process it. Once the user has filled the screen up with whatever, they just hit STOP followed by a single character editor command. The STOP key is trapped by an IRQ. It has to restore the IRQ vector to the factory value, replace the character underneath the cursor if it was winked on, and thrash its way out of the IRQ (drop the RTI address and the stashed register stuff off the machine stack) before transferring control to high level Forth. That's where the command is retrieved, things happen to the screen and buffers, and we are thrown back into the minimalist screen editor.
This word takes two arguments and toggles either the BRK vector or the IRQ vector between two addresses by applying XOR. Used for turning the STOP key IRQ hook on and off, and for switching between BRK to Sweet16 or BRK to TIM (Terminal Interface Monitor)
The TRS-80 Model I had something even worse, to wit:
Quote:
EDIT L
Enters edit mode for a particular line L.
In edit mode, the following keystroke commands are available:
SPACE moves the cursor one character to the right.
BACKSPACE moves the cursor one character to the left.
D deletes the character at the current position.
ID deletes I characters.
I enters insert mode. In insert mode, characters are inserted as they are typed.
SHIFT-[ leaves insert mode.
Pressing RETURN ends insert mode, enters the changes made, and returns to the READY prompt.
Enters edit mode for a particular line L.
In edit mode, the following keystroke commands are available:
SPACE moves the cursor one character to the right.
BACKSPACE moves the cursor one character to the left.
D deletes the character at the current position.
ID deletes I characters.
I enters insert mode. In insert mode, characters are inserted as they are typed.
SHIFT-[ leaves insert mode.
Pressing RETURN ends insert mode, enters the changes made, and returns to the READY prompt.
During senior year of high school, 1979-1980, sometimes they would let me play on the Digital Equipment machine running TOPS-20 at Delta College in Saginaw. I actually liked TECO. The fastest I ever got with a code editor was on EDT on VAX/VMS circa late '80s. That thing was hooked up to the numeric keypad and it became second nature. Nowadays I use notepad clones (Geany) or vi, or rarely emacs.
But the Commodore 8-bits, they all have the coolest full screen editor! Also a graphics character set and lowercase. Move the cursor anywhere, hit return anywhere on the line and it parses the whole thing. A PET screen is exactly 1K consisting of 40x25 screen codes plus 24 bytes of 40/80 column "line wrap table". Rather than implement the Leo Brodie editor, I'm just going to marry Forth blocks to the Commodore screen editor. And today I got the STOP button to function as an ESC key. It isn't perfect yet, but I can tell it is going to work.
I'll stash piles of screens into a buffer that grows downward from the top of RAM until it bumps into the dictionary growing in the opposite direction. The entire buffer space will be stored in PRG files. That means it will work with a single magnetic storage device, either on cassette or disk. I'll bury the mass storage interface (just need "LOAD" and "SAVE" and maybe "VERIFY") inside the editor and I won't require FLUSH and SAVE-BUFFERS. BLOCK will merely uncompress one of the screens into a shadow video area ($7C00-7FFF). The lowest block number is 1. The highest block number is limited to how many buffers are currently in RAM. Attempting to access a block outside of that range will ABORT" BLOCK OUT OF RANGE"
The core of the editor is really simple. I hook the iRQ to trap the STOP key (my escape key) and dump out into a tight machine language loop to accept a line of text using the ROM editor, but don't process it. Once the user has filled the screen up with whatever, they just hit STOP followed by a single character editor command. The STOP key is trapped by an IRQ. It has to restore the IRQ vector to the factory value, replace the character underneath the cursor if it was winked on, and thrash its way out of the IRQ (drop the RTI address and the stashed register stuff off the machine stack) before transferring control to high level Forth. That's where the command is retrieved, things happen to the screen and buffers, and we are thrown back into the minimalist screen editor.
- EDIT ( -- ; invoke the editor )
general
STOP STOP - nothing happens. The editor continues to wait for the second keypress
STOP any other key that isn't listed below - still nothing happens. The editor continues to wait for the second keypress
STOP SPACE - cancel editor command, return to edit mode
STOP Q - save the current screen to the buffer, drop out of the editor to the Forth command line
STOP CLR - reset linewrap table to all 40-char lines (not too sure about this one)
screen navigations
STOP HOME - first screen
STOP UP - previous screen (create one if necessary)
STOP DOWN - next screen (create one if necessary)
STOP INS - insert a blank screen in front of the current screen
STOP DEL - delete the current screen. Replace it with the next screen. If there's no next screen replace it with the previous screen. If there's no previous screen show a blank screen.
STOP I - index, displays top line (first 40 characters) of all active buffers (max 25). User can move the cursor to any index line and hit return to edit that screen.
mass storage
STOP S - save all screens to a named file to disk or tape
STOP L - load a named file of screens from disk or tape
STOP V - verify memory vs. a file on mass storage
line copy/paste buffer
STOP Z - zilch the paste buffer at PAD. Do or do not. There is no undo.
STOP X - cut the current logical line (40 or 80 characters), append to paste buffer. Move stuff up from the bottom of the screen. (like "dd" in vi)
STOP C - copy the current logical line, append to paste buffer
STOP V - paste (insert) the entire buffer (whole lines only) above the line the cursor is on (like "P" in vi)
This word takes two arguments and toggles either the BRK vector or the IRQ vector between two addresses by applying XOR. Used for turning the STOP key IRQ hook on and off, and for switching between BRK to Sweet16 or BRK to TIM (Terminal Interface Monitor)
Code: Select all
;--------------------------------------------------------------
;
; TOGGLEIRQ ( eorvalue $90|$92 -- )
;
toggleirq
sei
ldy #0
lda (tos),y
eor stackl,x
sta (tos),y
iny
lda (tos),y
eor stackh,x
sta (tos),y
cli
jmp poptwo ; [20 bytes]
Usage:
HEX
: ENTEREXITEDIT [ E455 STOPKEYIRQHANDLER XOR ] LITERAL 90 TOGGLEIRQ ;