| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A feature is hereby introduced into linenoise whereby
completion mode can be entered via Ctrl-X Tab also, not only
Tab. This is distinguished with a flag in the completion
structure. The intent is that the callback can use this to
provide substring matches not only prefix matches.
* linenoise/linenoise.c (complete_line): Takes a new argument,
and stores it in the new substring member of
lino_completions_t.
(edit): If Tab is typed while in Ctrl-X extended mode,
then fall through to the regular switch, where the TAB
case now recognizes that it is in extended mode and passes
the mode flag to complete_line.
* linenoise/linenoise.h (lino_completions_t): New member,
substring.
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): The recall previous word,
atom and line features now offset relative to the current
navigation position in the history. Previous line means
the line before the currently showing history line, not the
line most recently entered into the history.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Extended Ctrl-X Ctrl-R/r
command added.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit_move_sol): If the cursor
is already at the beginning of a line, then move it
to the start of the buffer.
(edit_move_eol): If the cursor is at the end of the
line, then move it to the end of the buffer.
This also fixes a bug: previously, if the cursor was
at the end of the line already, it moved to the end
of the following line.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Aborting a multi-line search result with Ctrl-C
messes up display because the row-related values
are being done on a linenoise copy, and their latest
values aren't backpropagated to the master lino_t.
* linenoise/linenoise.c (copy_display_params): New
static function.
(history_search): Use the lino_t copy when clearing the
screen, because lino_clear_screen manipulates a display
parameter. When leaving the function, copy the latest
display-related parameters from lc to l, so that l has
the latest number of columns and all the right row stuff
for multi-line mode.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Do paren_jump after
backspace
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (find_nearest_paren): New static
function.
(edit_move_matching_paren): Use find_matching_paren to
usefully handle situations when the cursor is not on
a parenthesis, bracket or brace.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (lino_clear_screen): Set
l->maxrows to zero so that refresh_multiline won't emit
useless upward cursor movement sequences. These have nowhere
to go from the top line of the screen.
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): After coming back
from a Ctrl-Z suspend, set l->maxrows to zero to force
refresh_multiline to draw the buffer from the current
cursor position down, without any retrograde cursor movement
to above lines, trying to refresh existing lines which
are not there.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The switch to Ctr-A/Ctrl-E within a logical line
breaks when the edit_move_end function is relied upon
to go to the end of the buffer.
* linenoise/linenoise.c (edit_move_home): Restored
to original behavior.
(edit_move_sol): New static function that hosts new
behavior of edit_move_home: calls edit_move_home in
single-line mode, or implements move within logical
line in multi-line mode.
(edit_move_end): Restored to original behavior.
(edit_move_eol): New static function that hosts new
behavior of edit_move_end: calls edit_move_end in
single-line mode, or implements move within logical
line in multi-line mode.
(edit): Call edit_move_sol instead of edit_move_home,
and in editing functions onyl, call edit_move_eol
instead of edit_move_end.
|
|
|
|
|
|
|
|
| |
* linemode/linemode.c (edit_move_home, edit_move_end):
Check for multi-line mode and implement movement
within the physical line.
* txr.1: Documented.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (SPACE): Preprocessor symbol
removed; was only referenced in the edit_delete_prev_word
function.
(edit_delete_prev_word): Recognize carriage return as
word-separating whitespace.
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (screen_rows): Restructured.
Calculates correct cursor rows (out.rows[1]). It's now
possible that the reported cursor row exceeds the number of
rows (out.rows[0]), because the cursor is on the last line,
which itself doesn't wrap, but the cursor does.
(refresh_multiline): Cursor wrapping calculation is
simple now: just check that nrow > rows.
Coalesced code for dealing with cursor position.
|
|
|
|
|
| |
* linenoise/linenoise.c (refresh_multiline): Fix size_t
being passed to %d conversion specifier in snprintf call.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (sync_data_to_buf):
Maintain a colum variable which is reset when
a new line is put out and takes into account
the prompt length; use this for tabs.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (history_search, sync_data_to_buf,
screen_rows, paren_jump, edit_move_matching_paren):
Fix signed/unsigned warnings.
(edit_in_editor): Avoid using template as a variable name.
Use const char * for string literal.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (paren_jump): Scan forward also,
if reverse scan turns up nothing, thereby jumping
to a closing parenthesis in the forward direction.
* txr.1: Documentation updated.
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Implemented.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (scan_match_fwd, scan_fwd,
edit_move_matching_paren): New functions.
(edit): New Ctrl-] command implemented using
edit_move_matching_paren.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit_delete_line): New
static function.
(edit): New Ctrl-K extended command case implemented using
edit_delete_line.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit_delete_prev_all):
In multi-line mode, delete only to beginning of physical
line, not the entire logical line.
Also, detect noop cases and don't do record undo
or produce any effect.
(edit_delete_to_eol): New function.
(edit): Use edit_delete_to_eol function for Ctrl-K instead of
inline code.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Sometimes edits don't do anything, and so the undo item
recorded for them is superfluous. When undo is used
nothing appears to happen for a turn.
We use two strategies: detect the noop change
and avoid recording the undo (or doing anything),
or else detecting the noop undo afterward and
removing it from the undo stack.
* linenoise/linenoise.c (remove_noop_undo): New static
function.
(edit_delete, edit_backspace): Remove noop undo.
(edit_delete_prev_word): Don't record undo, move
memory or update vars if there is no word to delete.
(edit_in_editor): Remove noop undo.
(edit): For Ctrl-T, don't record undo or do anything
other than clear the selection if the cursor
is leftmost already.
|
|
|
|
|
|
| |
* linenoise/linenoise.c (restore_undo): If an undo
item wants to produce a completely blank line,
then discard and skip it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This has to be done because each time a history line is added,
or taken back, the relative numbers change.
* linenoise/linenoise.c (undo_pop): New static function.
(restore_undo): Skip undo items which refer to lines of
history which no longer exist. Restore history[0] also.
(renumber_undo_hist): New static function.
(edit): When leaving, and removing the extra history
line representing the current line, renumber the undo
items by -1.
(lino_hist_add): After adding a line, bump the undo item
history indices by 1.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Changing most returns
to goto out. We have common clean-up to do, namely
removing the last history item which represents the
current line. This fixes a bug: not removing the
history line in the Ctrl-C case.
|
|
|
|
|
|
|
|
|
|
| |
If we don't move the cursor to the end, then
the shell prompt (Ctrl-Z) or next REPL prompt (Ctrl-C)
comes in the middle of the previous input.
* linenoise/linenoise.c (edit): in multi-line mode,
move to end of input on Ctrl-C. On Ctrl-Z suspend,
do the same, but save and restore the position.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (LINENOISE_MAX_UNDO): New preprocessor
symbol.
(struct lino_state): New member, undo_stack.
(struct lino_undo): New struct type.
(free_undo, record_undo, record_triv_undo, restore_undo):
New static functions.
(edit_insert): Record trivial undo item with record_triv_undo.
(edit_insert_str, edit_history_next, edit_delete,
edit_backspace, edit_delete_prev_all, edit_delete_prev_word,
edit_in_editor): Record undo item.
(edit): Record undo item before Ctrl-R history recall and
Ctrl-T twiddle. Also record one final undo item upon Enter, as
well as Ctrl-C. New Ctrl-O command to undo.
(lino_copy): Do not copy undo_stack, to prevent double
freeing.
(lino_free): Free the undo history.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (struc lino_state): New member,
clip, sel, end, dsel, dend, need_refresh, selmode.
(sync_data_to_buf): Update the sel and end members
of the structure based on dsel and dend, the way
pos is being updated from dpos.
(refresh_singleline, refresh_multiline): If visual selection
mode is in effect, show the selected region in inverse video.
(update_sel, clear_sel, yank_sel, delete_sel):
New static function.
(edit_insert): Delete the selection before inserting, so that
the character appears to replace the selection.
Set need_refresh flag instead of calling refresh_line.
(edit_insert_str): New static function. Inserts string,
replacing existing selection, if any.
(paren_jump, edit_move_left, edit_move_right, edit_move_home,
edit_move_end, edit_history_next): Set new
need_refresh flag instead of calling refresh_line directly.
(edit_delete): If selection is in effect, just delete the
selection and return. Set need_refresh flag instead
of calling refresh_line.
(edit_backspace): If selection is in effect, and selection
is not inverted (cursor is to the right of selection)
then just delete the selection. Otherwise delete the
selection, and perform the backspace. Set need_refresh flag
instead of calling refresh_line.
(edit_delete_prev_word): Delete the selection and the word
before the selection. Set need_refresh flag
instead of calling refresh_line.
(edit_in_editor): Set need_refresh_flag instead of
calling refresh_line, and cancel visual selection mode.
(edit): Clear selection mode on entry. Update the selection
variables on each loop iteration. Honor the need_refresh
flag. New commands implemented: Ctrl-S, Ctrl-Q, Ctrl-X Ctrl-Q.
Some commands need to set need_refresh flag.
Some need to cancel selection mode.
(lino_copy): Set the clip member of the cloned structure
to null, otherwise there will be a double free of the
clipboard buffer.
(lino_cleanup): Free the clipboard and null out the pointer.
* txr.1: Documented visual select.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (sync_data_to_buf): prompt argument
removed. The value passed is always l->mlmode, and that
is what it indicates.
(complete_line, complete_line, sync_data_to_buf,
refresh_multiline, edit_insert): Updated calls.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (struct lino_state): New members
atom_callback and ca_ctx.
(lino_set_atom_cb): New function.
(edit): Ctrl-X Ctrl-A invokes atom callback, and inserts
returned string.
* linenoise/linenoise.h (lino_atom_cb_t): New function pointer
typedef.
(lino_set_atom_cb): Declared.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Ctrl-X Ctrl-W,
or Ctrl-X w, with an optional number in between,
cause a word from the previous line to be inserted.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is so that when a command line is edited in an external
editor, editors can choose appropriate syntax highlighting
mode based on the suffix.
* linenoise/linenoise.c (struct lino_state): New member,
suffix.
(edit_in_editor): If we have the mkstemps function, then
use it to create a suffixed name.
(lino_set_tempfile_suffix): New function.
* linenoise/linenoise.h (lino_set_tempfile_suffix): Declared.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Support a verbatim
entry mode with limited commands, in which most
characters self-insert, including Enter.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (lino_get_multiline): New function.
* linenoise/linenoise.h (lino_get_multiline): Declared.
* parser.c (listener_hist_len, listener_multi_line_p_s): New
symbol global variables.
(repl): Set linenoise history length and multi-line mode from
the *listener-hist-len* and *listener-multi-line-p* variables
on each call. Set the *listener-multi-line* variable from
the lino_t object's current state after each linenoise call.
(parse_init): Initialize new global variables and register
them as special variables.
* txr.1: Update sentence which says that history is fixed
at 100 lines. Document listener configuration variables.
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (tr, edit_in_editor): New
static functions.
(edit): edit_in_editor hooked in under Ctrl-X Ctrl-E.
* txr.1: Documented.
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Handle the Ctrl-X
key by setting a temporary flag. This sets the framework for
commands prefixed by Ctrl-X.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The oldpos variable for tracing the previous cursor position
as an absolute offset into the display data is not appropriate
any more under enhanced multi-line mode. The reason is that
edit operations can completely replace the buffer (e.g.
history recall). When the buffer is replaced, because there
can be arbitrary line breaks in the data, the oldpos
variable's saved position has no meaning relative to the new
buffer contents. But the only use of oldpos is to calculate
the previous *row* of the cursor position! So, we can replace
oldpos with a variable that just remembers the row directly.
As a bonus, we can get rid of the calculation which tries to
recover the oldrow from oldpos.
* linenoise/linenoise.c (struct lino_state): Removed member
oldpos. Added member oldrow.
(struct row_values): Array reduced to two elements.
(screen_rows): Doesn't take oldpos argument any more.
Current cursor position returned in out.rows[1].
(refresh_multiline): Some variables renamed. rpos2 becomes
nrow (new row position). old_rows is oldmaxrows to avoid
confusion with l->oldrow. The rpos variable (old row
position) is gone: its uses are replaced with l->oldrow.
Near the end of the function, we save the new cursor row
position (nrow) in l->oldrow, in the same spot where
we previously saved the current position in l->oldpos.
(edit): Initialize l->oldrow to 0. Remove initialization
of l->oldpos.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (lndebug): Macro removed.
The variables have changed; it won't work any more.
We have GDB.
(refresh_multiline): lndebug calls removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The linenoise multi-line mode is just a glorified line
wrapper, and not actualy a multi-line editor, like in GNU
Readline and others. This commit fixes it. The edit buffer can
now contain line breaks, separated by carriage return
characters. (In single-line mode, these characters continue
to be displayed as ^M). The row and column calculations in the
multi-line refresh follow this data representation.
* linenoise/linenoise.c (sync_data_to_buf): This function
now takes an extra argument telling it whether multi-line mode
is in effect for the rendering. In multi-line mode, the prompt
is now added to the display data, so that multi-line refresh
is simplified by not having to account for the prompt length
in various calculations. Also, in multi-line mode, carriage
returns are rendered to display as CR-LF pairs, since they
denote embedded line breaks.
(complete_line): Pass mlmode to sync_data_to_buf.
(struct row_values): New struct, for returning multiple
row values out of a function.
(screen_rows, col_offset_in_str): New static functions.
(refresh_multiline): Modified to use screen_rows and
col_offset_in_str for its calculations, and not to deal with
the prompt at all, since the prompt is rolled into the display
data.
(refresh_line, edit_insert): Pass mlmode to sync_data_to_buf.
* txr.1: Documented multi-line mode.
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (lino_hist_load): Don't look for
and overwrite carriage returns with the null character; only
do that for newlines. We already handle embedded carriage
returns just fine by displaying them as ^M.
There is a plan to use these characters for breaking up lines
in an enhanced multi-line mode.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (sync_data_to_buffer): Add
missing null terminator to l->buf. This hasn't
caused a problem because no code relies on it
being a C string. That may be about to change.
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Handle CTL('J')
by toggling mlmode and refreshing the line.
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Delete if the data
length is nonzero, not the display length.
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (LINENOISE_PAREN_DELAY): New
preprocessor symbol.
(scan_match_rev, scan_rev, usec_delay, paren_jump):
New static functions.
(edit): Handle closing parenthesis, bracket and brace
by inserting and calling paren_jump.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (struct lino_state): New member,
need_resize.
(lino_list_busy): New static variable.
(handle_resize): New function.
(complete_line, history_search, edit): Check for the tty read
being interrupted, and in that case call handle_resize to put
the resize into effect, and continue the loop to fetch another
character.
(sigwich_handler): New function.
(linenoise): If we have SIGWINCH, install a handler for it
temporarily.
(link_into_list, unlink_from_list): Set global busy flag
around list manipulations. The signal handler stays away if
these are set. This means that if the user performs some
action that requires a lino_t to be constructed (e.g. types
Ctrl-R to search), while resizing the window at almost exactly
the same time, we will lose the resize signal. Oh well!
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (history_search): Editing keys
should leave search mode and be processed in command mode.
Also, let's have Ctrl-L and Ctrl-Z work, but stay in search
mode.
* txr.1: Documented.
|
|
|
|
|
|
| |
* linenoise/linenoise.c (history_search):
Don't step through identical lines, which
looks as if Ctrl-R is being ignored.
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (compare_completions): Restructure
with help of new lino_copy function to collect completions
just for the prefix of the line up to the cursor position,
and recombine those with the suffix.
* txr.1: Doc updated.
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (complete_line): ESC must not be
treated specially when leaving completion mode; it must
accept the completed line. The original code did this wrong
in my opinion and I propagated the error.
* txr.1: Remove all mention of special ESC treatment
in completion mode.
|