diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-21 06:07:46 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-21 06:07:46 -0700 |
commit | 1de86c685ff9a4a36014188c8ef24601d704157c (patch) | |
tree | 177f5a31c640c13f0466b4cb68b868dc5dee1b30 /txr.1 | |
parent | bf953d07cf4caa822677b64cae5e8fc444bcdfe2 (diff) | |
download | txr-1de86c685ff9a4a36014188c8ef24601d704157c.tar.gz txr-1de86c685ff9a4a36014188c8ef24601d704157c.tar.bz2 txr-1de86c685ff9a4a36014188c8ef24601d704157c.zip |
linenoise: much more sane, per-history-item undo.
Undo now works intuitively. It does not perform invisible
jumps among history items, restoring instead just the history
for the given line being edited.
* linenoise/linenoise.c (LINENOISE_MAX_UNDO): Raised from 32
to a more generous 200. Since edits are per-history line,
it makes sense to allow a lot more.
(delete_undo): New static function.
(free_undo): Static function removed to free_undo_stack.
Trivial loop around delete_undo.
(record_undo): Do not record the current history index; all
edits are assigned the index INT_MAX. INT_MAX is an indicator
that the edits do not have an assigned history line. The
decision of where to assign them depends on whether history
navigation is used to move to another history line or
Enter is used to submit an edited line.
A stinky part of the history trimming code is rewritten
simply in terms of delete_undo.
(record_triv_undo): Suppress a trivial item only if
the top item belongs to the same history line, or is
nonspecific (INT_MAX).
(undo_pop): Static function removed.
(restore_undo): Rewritten to look for the topmost item
specific to the current history line or an INT_MAX nonspecific
item. Removes undo items for expired lines as it goes.
(undo_subst_hist_idx): New static function.
(renumber_undo_hist): Renamed to undo_renumber_hist_idx.
(edit_history_next): Do not record an undo; history navigation
is no longer considered an edit. Rewrite all the INT_MAX
entries in the undo stack with the current history index,
permanently associating the undo items with the history line
away from which we are navigating.
(edit): Do not record an undo for a line terminating with
Enter. It is not an edit action. When leaving the funtion,
renumber any INT_MAX entries in the undo history to history
index zero. Thus edits to any line which is submitted via
Enter will (correctly) not be associated with that line,
which was not in fact edited, but with the new line that was
submitted.
(lino_cleanup): Follow rename of free_undo.
(lino_hist_add): Follow rename of undo_renumber_hist_idx.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 47 |
1 files changed, 28 insertions, 19 deletions
@@ -33821,31 +33821,40 @@ when written out to the file. Conversely, when the edited file is read back, its newlines are converted to carriage returns, so that multi-line content is handled properly. (See the following section, Multi-Line Mode). -.NP* Undo +.NP* Undo Editing -The listener provides an undo feature. The Ctrl-O editing command will -restore the edit buffer contents and cursor position to the state in which -it was before a previous edit, or previous history navigation. +The listener provides an undo feature. The Ctrl-O command ("old", "oops") +restores the edit buffer contents and cursor position to a previous state. -Undo history is retained between lines. That is, after a line is submitted -with Enter, it is still possible to undo previous edits. Moreover, if a line -is canceled with Ctrl-C, such that it is not recorded in the recall history, it -is still available from the undo history. +There is a single undo history which records up the 200 most recent edit +states. However, the states are associated with history lines, so that it +appears that that undo history has its own, independent undo history. +Undoing the edits in one line has no effect on the undo history of another +line. + +Undo also records edits for lines that has been canceled with Ctrl-C, and are +not entered into the history, making it possible to recall canceled lines. + +The undo history is lost when \*(TX terminates. -Undo is limited to 32 states. Furthermore, the undo history is lost -when \*(TX terminates. +Undo doesn't save and restore previous contents of the clipboard buffer. -Undo doesn't restore previous contents of the clipboard buffer. +There is no redo. When undo removes an edit to restore to a prior edit state, +the removed edit is permanently discarded. -Undo will restore edits made to history lines. It does so unconditionally, -which means that it can introduce edits in the following situation. -When a history line is edited and then sumbitted without navigating to -a different history line, the edit isn't permanent. However, when the -edits are retraced via undo, the restored states -.I are -stored in the history. +Note that if undo is invoked on a historic line, each undo step updates that +history entry instantly to the restored state. This is in contrast +to the way new edits work. New edits are not committed to history until +navigation takes place to a different history line. -There is no redo; undoing is permanent. +Also note that when new edits are performed on a historic line and it is +submitted with Enter without navigating to another line, the undo information +for those edits is retained, and belongs to the newly submitted line. The +historic line hasn't actually been modified, and so it has no new undo +information. However, if a historic line is edited, and then navigation takes +place to a different historic line, then the undo information is committed to +that line, because the modifications to the line have been placed back +in the history entry. .SS* Visual Selection Mode |