-
-
Notifications
You must be signed in to change notification settings - Fork 27
Description
A Tedit stream has 2 personalities, as the basis for interactive text editing and as a Medley file stream. I don't think all the details of their behavior and how they interact were worked out in the Venue years.
On the one hand a Tedit stream is set up as a normal text editor that supports selection, insertion, deletion, looks-changes etc. Typically those are specified by on-screen keyboard actions, but there are also public functions (TEDIT.INSERT, TEDIT.DELETE, TEDIT.GETSEL, TEDIT.SETSEL and others) that allow programs to manipulate the stream whether or not it is on screen. (If it is onscreen and those functions are called, the screen is updated to reflection the changes).
On the other hand, the Tedit stream acts (mostly) like a Medley file stream. You can read from it, write from it, move the file pointer around, etc. Importantly, Tedit using the stream interface internally for line formatting and display, as changes are made through the editing interface. Also for hardcopy.
The behavior we inherited from Venue leaves some things to be desired.
- The Tedit BOUT doesn't actually act like BOUT's on other file streams. Normally, if BOUT is called when the file is positioned at a particular byte in the middle of the stream (GETFILEPTR), the character at that position is replaced by the new character. But Tedit's BOUT currently doesn't do an insertion, it does a replacement. It inserts the new character in front of the character at that position, everything at that position and beyond is pushed back, and 1 is added to the length of the stream. (There is no difference in the typical case when appending to the end of the stream.)
The current behavior seems wrong. OK to change it from insert to replace?
-
Edit insertions are typically undoable. Since BOUT is currently going through the standard character inserter, the bouting is also undoable. The history list will get very long, and every sequence of BOUT's will be undoable possibly as a single event. Is this a good idea?
-
Tedit treats image objects as pseudo-characters, with respect to most internal operations. This leaks over into the stream interface, in that BIN will return an image object if it is the next character at the file ptr. Should BOUT also be able to install an image object, to complete the analogy? Currently a separate object-inserting functions is need to insert an object.
-
If the stream is being displayed and a character is bouted, should the screen update? What if a character is bouted (insertion or replacement) in a part of the stream that is not currently visible. Should the display scroll to show where the change happened? That's what happens if the caret is off screen and a character is typed.
Those are the easy questions. The more difficult and confusing issues concern the stream/edit interactions. The edit operations can step on the file pointer in a way that is difficult for a stream-client to predict.
For editing the selection has a notion of the insertion point (the caret), that moves around through the editing interface (clicking etc). If you type, that's where the character gets inserted. Sometimes GETFILEPTR will give you the caret's byte position, but you can't count on that. SETFILEPTR will set the file pointer without changing the selection, so that the two diverge. And displaying lines may change the file pointer implicitly, since the formatter sets the file pointer in order to do its internal binning. The worse case is scrolling: the selection stays where it is (even if no longer visible) but the file pointer moves to the position at the end of the last line updated on the display.
Even if the lines are not being displayed, if you use the TEDIT.INSERT/TEDIT.DELETE operations on a selection at a position before what you think is the current file position, you can get unexpected results. Suppose you get the file ptr and save it, because you want to restore it after something else you want to do. If then you insert 5 characters before that position, setting the file pointer back to that saved value will point to a character 5 before what you thought it was pointing to before. (And again, if the display is running, the position will depend on the character of the last changed line in the window.)
Is there a sensible way of arranging the interaction of these two modes? Or should they be made mutually exclusive--a stream is either in edit/selection mode or bin/bout/fileptr mode, and you have to explicitly switch between those modes.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status