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 /combi.h | |
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 'combi.h')
0 files changed, 0 insertions, 0 deletions