Skip to content

11.LineEditor

Matteo Vitturi edited this page Jun 19, 2024 · 5 revisions

Block Editor

This page is kept for historycal reasons because a Full Screen Editor is available via NEEDS EDIT that can be used modify any Screen once you made it the Current Screen using the LIST word. For example, you can give 11 LIST to display the content of Screen # 11 and then EDIT to directly edit it. The Line-Editor itself is formed by a group of half-a-dozen definitions. See the dedicated Wiki-page for details.

Instead, the following definitions are available after you give needs editor or, if you’re using the original blocks file, 180 LOAD. Line Editor is formed by a dozen words that can operate on a single line of a given Screen and helps inspect things around.

An edit session normally starts with a LIST on the desired Screen, this sets SCR user variable to the passed Screen number. LIST is a word already available in the “core” dictionary. To clear a Screen I foreseen a BCLEAR word, but I left it commented for now, deeming it too dangerous for my tastes; instead I usually use BCOPY from an actually empty Screen.

The word FLUSH flushes to disk any modification you’ve done on any Screen. Beware, a modified Screen’s block is re-written to disk as soon as the buffer containing it are requested by another Screen. This implementation provides seven buffers: This should be enough to operate on three Screens (two blocks each) allowing one more BUFFER for a possibly "error message" block to be fetched from disk.

EMPTY-BUFFERS is another vital word: it empties all buffers. It is very useful if you mistakenly overwrite or spoil a Screen during an edit operation, with it, you have the chance to “rollback” the things before the anything is written to disk.

To write a line from scratch or to overwrite line, you can use P to “put” the following text to the given line on current screen. For example:

1000 LIST
0 P \ One thousand screens
L

This sequence selects Screen #1000 and put a text “One thousand screens” on the first line of it. The word L repeat the LIST of current screen.

To move or copy a line around, you can use H to “hold in PAD” a given line on current screen, you can change Screen if you wish, then you can complete this copy-and-paste operation with INS to “insert” or RE to “replace” the line you copied in advance with H. None of above words, but H, modify PAD content, so you can repeat the operation. There is also a way to cut-and-paste a line using D to “delete and copy to PAD” instead of H.

See also BLOCK, INDEX, L/SCR, LIST, LOAD, MESSAGE, PAD, SCR, STRM., TIB.

This is a quick reference of involved memory areas and words that work on them.


    |  Input       |  Parsing   |         |      Edit      |         |          |
    |  Buffer      | Operation  |         |    Operation   |         |          |
    |    TIB       |   TEXT --> |   PAD   | <-- H  RE  --> |  BLOCK  | <-- E    |
    |              |        --> |         | <-- D  INS --> |         | <-- S    |
***

-MOVE ( a n --- ) “Line move”. It moves a line, C/L bytes length, from address a to the line n of current screen, then it does an UPDATE. Current screen is the one kept by SCR.

B ( --- ) “Back” one Screen. This word set to previous Screen by decreasing SCR and prints it using LIST.

D ( n --- ) “Delete” a row. It deletes line n of current screen (the one indicated by SCR), the following lines are moved up and the last one will be blanked. D executes H so that it can be followed by an INS to perform a line move.

BCOPY ( n1 n2 --- ) “Block-Copy” utility that copies Screen n1 to Screen n2. SCR will contain n2.

E ( n --- ) “Erase” a row. This word fills line n with spaces. It does UPDATE.

H ( n --- ) “Hold” a row in PAD. This word put line n of current Screen to PAD without altering the block on disk. Current Screen is the one kept in SCR.

INS ( n --- ) “Insert” from PAD. This word inserts line n using text in PAD. The original line n and the following ones are moved down and the last is lost.

INVV ( --- ) “Inverse video”. It enables Inverse-Video attribute mode. See also TRUV.

L ( --- ) “List” current Screen. This word does SCR @ LIST.

LINE ( n --- a ) It leave the address a of line n of current screen, the one kept in SCR. Such a screen is currently held in a buffer.

N ( --- ) “Next” Screen. This word sets to next Screen by increasing SCR and prints it using LIST.

P ( n --- ) “Put” a line. This word accepts the following text (delimited by a tilde character ~) as the text of line n of current Screen. Text is taken from TIB and sent to the current Screen

RE ( n ---) “Replace”. This word takes text currently in PAD and put it to line n.

S ( n --- ) “Space” one row. This word frees line n moving the following lines down by one. The last line is lost

ROOM ( --- ) This word shows the room available in the dictionary, that is the difference between SP@ and PAD.

TEXT ( c ---) This word accepts the following text and stores it to PAD. c is a text delimiter. TEXT does not go beyond a 0x00 [null] ASCII.

TRUV ( ---) “True video”. It disables Inverse-Video attribute mode. See also INVV. Questa definizione è disponibile solo dopo il caricamento del “Line Editor” tramite 10 LOAD.

WHERE ( n1 n2 --- ) Usually executed after an error has been reported during a LOAD session. Maybe, this word should be included in “core” dictionary. n1 is the value of IN and n2 the value of BLK as were left by ERROR. WHERE shows on screen the block number, the line number, the very same line highlighting in “inverse video” the word that caused the error.