summaryrefslogtreecommitdiffstats
path: root/linenoise
Commit message (Collapse)AuthorAgeFilesLines
* linenoise: raise line length from 1023 to 4095.Kaz Kylheku2019-02-261-1/+1
| | | | | | * linenoise.c (LINENOISE_MAX_LINE): Change to 4096. * txr.1: Updated.
* linenoise: deal with some lingering line wrap glitch.Kaz Kylheku2019-02-261-0/+6
| | | | | | | | | | | | | | | | | | The optimized character insert case must handle the situation of the cursor going off the edge of the screen when a character is output in the last column in a manner that is consistent with the regular insert, leaving the linenoise structure in the same state that a full refresh would. * linenoise/linenoise.c (refresh_multiline): In the optimized character insert case indicated by need_refresh == 2, we must add the check for the cursor being in the dead spot past the edge of the screen, just like we do later in the function for the regular refresh case. In that case we must advance the cursor to the next line to get it out of the dead spot, and adjust maxrows if necessary. We know we are in the dead spot from the two rows values output by screen_rows. That function puts out a nrow value that exceeds rows when that is the case.
* linenoise: defensive null pointer check.Kaz Kylheku2019-02-261-1/+2
| | | | | | | | | | * linenoise/linenoise.c (move_cursor_multiline): If the npos argument happens to be equal to the current position (the operation is a null move), then no movement is generated. In that case, no ab_append operation is called, and ab.b will stay null; this null pointer then gets passed to lino_os.puts_fn as the string to output, and that will blow up. This situation hasn't actually been observed.
* linenoise: Ctrl-X Ctrl-P missing from cheatsheet.Kaz Kylheku2019-02-211-4/+4
| | | | | | | * linenoise/linenoise.c (show_help): Rearrange contents. ^X+Tab moves from page 3 to page 2, to a spot where there is just enough room. That gives us room to place ^X^P on page 3.
* linenoise: preserve too-large-to-read file.Kaz Kylheku2019-02-151-2/+11
| | | | | | * linenoise.c (edit_in_editor): If we can't read the file, then preserve the file, and replace the command line buffer with an error message in which the name of that file appears.
* linenoise: bugfix: vertical skip problem.Kaz Kylheku2019-02-141-1/+3
| | | | | | | | | | | | | | | | | | | | | This relates to the optimized insert at the end of the line. The following bug manifests itself. When the cursor is not at the bottom of the screen (e.g. fresh terminal after a clear screen), if blank lines are added to the buffer and then backspace is hit, the cursor strangely jumps down by multiple lines prior to the refresh. In a Windows CMD.EXE window, this shows up even at the bottom of the screen, because the CMD.EXE console responds to a downward movement (ESC[<n>B) beyond the bottom row by scrolling the screen, rather than clipping the movement. * linenoise/linenoise.c (refresh_multiline): When doing the elided refresh (l->need_refresh == 2), we must update not only l->maxrows but also l->oldrow. Otherwise when we do the real update, it will think that the cursor is on the first line, and try to move down to the last line.
* linenoise: fix multi-line mode regression.Kaz Kylheku2019-02-141-5/+16
| | | | | | | | | When Enter is input in multi-line mode, a ^M appears instead of advancing to the next line. When the display is refreshed, the ^M's are properly treated as line breaks. * linenoise.c (edit_insert): Let's restructure the conditional ladder here into a switch and handle ENTER by issuing CR-LF.
* linenoise: bugfix: caret notation in insert-at-end.Kaz Kylheku2019-02-051-1/+10
| | | | | | | * linenoise.c (edit_insert): In the optimized insertion case at the end of the buffer in multi-line mode, we must render control characters in the same manner as in the slow refresh case: namely, with the caret notatiion: ^@, ^A, ...
* linenoise: bugfix: caret notation for NUL.Kaz Kylheku2019-02-051-2/+2
| | | | | | | * linenoise/linenoise.c (sync_data_to_buf): The null character appears from the stream as 0xDC00. We must test for that and render it as ^@, counting a a width of two, rather than sending it to the terminal, counting as width of 1.
* linenoise: bugfix: regression in mlmode line wrap.Kaz Kylheku2019-02-051-1/+6
| | | | | | | | | | | | | | | | | | | | | The following problem happens: when charaters are inserted past the end of the line such that it wraps, hitting backspace or any cursor movement causes a spurious scroll. This was caused on Nov 1 2018 by bf85503b (linenoise: avoid refresh for new text in multi-line mode). The reason is that the maxrows variable isn't updated when we trivially add a character without repainting. * linenoise/linenoise.c (lino state): Document special value for need_refresh: when it is 2, the refresh doesn't perform a any output, but recalculates maxrows. (refreh_multiline): If need_refresh is 2, bail after updating maxrows. (edit_insert): When trivially adding a character at the end and just outputting it, if in multi-line mode, set need_refresh to 2.
* linenoise: use move_cursor in movement operations.Kaz Kylheku2018-11-011-36/+23
| | | | | | | | * linenoise/linenoise.c (edit_move_left, edit_move_right, edit_move_home, edit_move_sol, edit_move_end, edit_move_eol, edit_move_matching_paren): Use the efficient move_cursor instead of punching in the new position and calling refresh_line.
* linenoise: check for null move in move_cursor.Kaz Kylheku2018-11-011-0/+3
| | | | | * linenoise/linenoise.c (move_cursor): Do nothing if the requested position is current.
* linenoise: small move_cursor bugfix.Kaz Kylheku2018-11-011-0/+1
| | | | | | | | | | | * linenoise/linenoise.c (move_cursor): We must update the oldrow variable, expected by refresh_line to be tracking the row position of the cursor. This bug doesn't affect the current use of move_cursor for paren_jump, because that logic moves the cursor to the original position, which makes the oldrow value correct, and refresh_line is never called in between. If we want to use move_cursor in more situations, this has to be fixed.
* linenoise: fix use of int for wide char.Kaz Kylheku2018-11-011-1/+1
| | | | | | | * linenoise/linenoise.c (history_search): The c variable for capturing the input character should be of type wint_t, not int. This was caught by GNU C++, due to a signed/unsigned warning when c was compared to WEOF.
* linenoise: avoid refresh in paren matching.Kaz Kylheku2018-11-011-4/+51
| | | | | | | | | | * linenoise/linenoise.c (move_cursor_multiline, move_cursor): New functions. (paren_jump): Use move_cursor rather than refresh_line. In multi-line mode, this calculates the required cursor movement and emits the escape sequences to make it happen, without issuing a refresh, sending way less data to the terminal.
* linenoise: avoid refresh for new text in multi-line mode.Kaz Kylheku2018-11-011-3/+9
| | | | | | | | * linenoise/linenoise.c (edit_insert): This function is missing an important optimization for multi-line mode. Let's add it. Since multi-line mode doesn't scroll horizontally, it is very simple: if a character is added at the end, there is no need for refresh.
* linenoise: clear need_refresh in refresh_line.Kaz Kylheku2018-11-011-3/+3
| | | | | | | | | | * linenoise/linenoise.c (refresh_line): Clear the need_refresh flag here. (edit): No need to clear it here any more. This will prevent some useless calls to refresh_line. Some edit operations set refresh_line, but then execute something that performs refresh_line unconditionally. If the flag is then reset, the top of the loop doesn't have to do another wasteful refresh.
* linenoise: move modulo operation into function.Kaz Kylheku2018-11-011-3/+3
| | | | | | | | | * linenoise/linenoise.c (col_offset_in_str): Take a cols parameter and wrap the return value into the number of columns. (refresh_multiline): No need to do the % cols operation on the return value of col_offset_in_str any more; just pass cols down into it.
* linenoise: guard against setting cols to zero.Kaz Kylheku2018-11-011-1/+1
| | | | | | | | * linenoise/linenoise.c (get_columns): Avoid the situation that cols is zero or negative. The cols value is involved in a modulo calculation (position % cols), which requires cols not to be zero. The situation hasn't been observed; this is just defensive coding.
* linenoise: improve efficiency of warning flash.Kaz Kylheku2018-11-011-12/+20
| | | | | | | | | | | * linenoise/linenoise.c (usec_delay): return a Boolean indicator whether the delay was prematurely canceled by input. (flash): Use the return value of usec_delay to bail out of the loop early, canceling the flashing. Instead of doing full line refreshes to display and hide the exclamation mark, perform the flash by simply printing the exclamation mark at the current location and then erasing it with backspace-space-backspace.
* linenoise: bugfix: incorrect tests for WEOF.Kaz Kylheku2018-10-311-7/+7
| | | | | | | * linenoise/linenoise.c (complete_line, history_search, edit): The test c < 0 is not correct. Unlike EOF, WEOF isn't required to be negative, and in fact in the glibc environment, it isn't.
* listener: fix crash in selection yanking.Kaz Kylheku2018-06-201-1/+1
| | | | | * linenoise/linenoise.c (yank_sel): Use wmalloc_fn because the size is being measured in characters rather than bytes.
* listener: Cygnal fix.Kaz Kylheku2018-05-181-1/+23
| | | | | | | | | | | | | | | | The standard input and output streams are in text mode on Cygnal, which interferes with the listener, because it draws input from streams. Let's hack it by Cygwin-specific code in linenoise. * linenoise/linenoise.c (struct lino_state): New members orig_imode and orig_omode, on Cygwin/Cygnal only. (enable_raw_mode): As part of enabling raw mode, use the Cygwin setmode function to put both descriptors in binary mode, saving their previous mode. (disable_raw_mode): Revert the previous mode of both descriptors, in reverse order in case they are the same descriptor.
* listener: Cygwin fix.Kaz Kylheku2018-05-182-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | We cannot pass raw C wide literals to static_str; this breaks on platforms where wchar_t is two bytes and strings are aligned to only two byte boundaries. That's why TXR has the wli() macro. We don't want to introduce the wli() macro into linenoise, so the two choices are: duplicate the incoming mode strings into dynamic storage with string(), or pass some enum to specify file mode and locally convert to static mode string. Let's go with the latter. * linenoise.c (edit_in_editor, lino_hist_save): Use enum constant for file mode instead of mode string. * linenoise.h (enum lino_file_mode, line_file_mode_t): New enum. (struct lino_os): File opening functions use lino_file_mode_t instead of mode string. * parser.c (lino_mode_str): New static array. (lino_open, lino_open8, lino_fdopen): Take enum mode instead of string. Convert to literal through lino_mode_str table, and pass that literal to static_str.
* linenoise: switch to wide characters, support Unicode.Kaz Kylheku2015-09-222-358/+418
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (chk_wrealloc): New function. * lib.h (mem_t): Wrap with ifndef block. (MEM_T_DEFINED): New preprocessor symbol. (chk_wrealloc): Declared. * linenoise/linenoise.c (LINENOISE_MAX_DISP): Adjust to a reasonable value; just twice the number of abstract characters. The 8 factor had been chosen to cover the worst case that every character is mapped to a tab. (struct lino_state): Almost everything char typed turns to wchar_t. The TTY isn't referenced with Unix file descriptors, ifd and ofd, but abstract stream handles tty_ifs and tty_ofs. The ifs member isn't required any more since plain mode is handled via the tty_ifs stream. (mem_t): Declaration removed; now in linenoise.h. (chk_malloc, chk_realloc, chk_strdup_utf8): Declarations removed. (lino_os): New static structure. (nelem): New macro. (wcsnprintf): New static function. (enable_raw_mode, disable_raw_mode): Get Unix FD from stream using lino_os interface. (get_cursor_position, get_columns, handle_resize, record_undo, remove_noop_undo, restore_undo, undo_renumber_hist_idx, compare_completions, complete_line, lino_add_completion, next_hist_match, history_search, show_help, struct abuf, ab_append, ab_free, sync_data_to_buf, refresh_singleline, screen_rows, col_offset_in_str, refresh_multiline, scan_match_rev, scan_match_fwd, scan_fwd, find_nearest_paren, usec_delay, flash, yank_sel, delete_sel, edit_insert, edit_insert_str, edit_move_eol, edit_history_next, edit_delete, edit_backspace, edit_delete_prev_all, edit_delete_to_eol, edit_delete_line, edit_in_editor, edit, linenoise, lino_make, lino_cleanup. lino_free, free_hist, lino_hist_add, lino_hist_save, lino_set_result): Revised using streams, wide chars and lino_os interface. (lino_init): New function. * linenoise/linenoise.h (LINO_PAD_CHAR): New preprocessor symbol. (mem_t): Defined here. (MEM_T_DEFINED): New preprocessor symbol. (struct lino_os, lino_os_t): New structure. (lino_os_init): New macro. (struct lino_completions, lino_compl_cb_t, lino_atom_cb_t, lino_enter_cb_t): Switch to wchar_t. (lino_init): New function. (lino_add_completion, lino_make, linenoise, lino_hist_add, lino_hist_save, lino_hist_load, lino_set_result) * parser.c (find_matching_syms, provide_completions, provide_atom, is_balanced_line, repl): Adapt to wide character linenoise. (lino_fileno, lino_puts, lino_getch, lino_getl, lino_gets, lino_feof, lino_open, lino_open8, lino_fdopen, lino_close): New static functions. (linenoise_txr_binding): New static structure. (parse_init): Call lino_init, passing OS binding. * txr.1: Update text about the listener's limitations.
* linenoise: visual feedback for incomplete entry.Kaz Kylheku2017-09-071-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a line of input is incomplete and the cursor is at the end of that line, hitting Enter causes an uncomfortable ambiguity. Although the cursor moves to the next line, it is not clear whether that is because the input is being accepted, or whether the expression which was entered is executing. For instance, these appear to behave the same way: > (while t[Enter][Enter]... > (while t)[Enter][Enter]... One is just waiting for more input; the other is sitting in an infinite loop just echoing the newline characters. To partially address this issue, we introduce a visual feedback mechanism. When Enter is issued at the end of an incomplete line, then immediately after the insertion of Enter, the character ! is flashed twice, alerting the user that the line is incomplete. In other situations, there isn't any feedback. An infinite loop or lengthy calculation like (while t) looks the same as code which is reading input like (get-line). * linenoise/linenoise.c (LINNOISE_FLASH_DELAY): New macro. (flash): New static function. (edit): Call flash to flash the ! character when Enter is issued at the end of an incomplete line, and we are not in paste mode.
* linenoise: bugfix: cancel extended mode on Enter.Kaz Kylheku2017-09-071-0/+1
| | | | | | | | | | * linenoise/linenoise.c (edit): If Enter is processed while in Ctrl-X extended command mode, that mode must be explicitly canceled by resetting the extended local flag. Not doing this became an issue when the Enter callback mechanism was introduced to detect incomplete lines. At that point, entering Ctrl-X Enter on an incomplete line caused linenoise to insert a newline, but stay in extended mode.
* linenoise: replace linefeeds with CR in previous result.Kaz Kylheku2017-07-092-1/+3
| | | | | | | | | | | | | | This fixes the issue that when a multi-line result is pasted into the edit buffer with Ctrl-X P, the line breaks appear in it as linefeeds, displayed as ^J. In linenoise, we need line breaks to be carriage returns. * linenoise/linenoise.c (lino_set_result): replace newlines with carriage returns in the given string. * linenoise/linenoise.h (lino_set_result): Add comment that function takes ownership of memory assumed to be malloced, and that it modifies it.
* linenoise: support suspend and refresh in help.Kaz Kylheku2017-06-301-0/+11
| | | | | | * linenoise/linenoise.c (show_help): Handle Ctrl-Z and Ctrl-L commands, ensuring that the display stays on the same page when these are processed.
* linenoise: callback for checking syntax completeness.Kaz Kylheku2017-06-162-1/+23
| | | | | | | | | | | | | | | | | | | The idea is that when the user types Enter to submit a line, it can be checked whether it is complete syntax using a callback. If the callback indicates that the syntax is incomplete (there are open expressions, string literals or whatever), then Enter is inserted verbatim. This is active in multi-line mode only. * linenoise.c (struct lino_state): New members, enter_callback and ce_ctx. (lino_set_enter_cb): New function. (edit): If enter is issued, and multi-line mode is in effect, and there is an enter callback, then call it. If the callback returns false, then just insert the character. * linenoise.h (lino_enter_cb_t): New typedef. (lino_set_enter_cb): Declared.
* linenoise: Ctrl-X ? displays editing cheatsheet.Kaz Kylheku2017-06-141-0/+101
| | | | | * linenoise/linenoise.c (show_help): New static function. (edit): Call show_help on Ctrl-X ?.
* linenoise: support forcing of noninteractive mode.Kaz Kylheku2017-04-042-1/+14
| | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member, noninteractive. (lino_set_noninteractive, lino_get_noninteractive): New functions. (linenoise): Check noninteractive flag; if set, treat the situation like !isatty(ls->ifd). * linenoise/linenoise.h (lino_set_noninteractive, lino_get_noninteractive): Delared.
* linenoise: bugfix: use persistent stream for non-tty.Kaz Kylheku2017-04-031-12/+18
| | | | | | | | | | | | | | This bug causes data to be thrown away after reading one line. * linenoise/linenoise.c (struct lino_state): New member, ifs. (linenoise): Do not fdopen a new stream on each call, because this will read a buffer full of data, from which it will just read one line, and then throw the rest of away when fclose is called on the stream. Open the stream once and store it in the ifs member. (lino_cleanup): If the ifs member is non-null, then call fclose on it.
* linenoise: close descriptor before external edit.Kaz Kylheku2017-03-171-1/+6
| | | | | | | | * linenoise/linenoise.c (edit_in_editor): Close the file stream after writing out the temporary file, before launching the editor. On Windows, Notepad complains that the file is in use by another application and cannot write to it. Windows Vim treats the file as read-only in spite of good permissions.
* linenoise: Ctrl-X Ctrl-P edits result of command.Kaz Kylheku2016-10-122-0/+21
| | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member, result. (edit): Ctrl-P or p in extended mode cause result string to be inserted into the buffer. (lino_copy): Ensure result string in copy is null. (lino_cleanup): Free result string and set to null. (lino_set_result): New function. * linenoise/linenoise.h (lino_set_result): Declared.
* linenoise: bug in resubmit historic line when dupe.Kaz Kylheku2016-10-121-2/+4
| | | | | | | | | | | When Ctrl-X Enter is used to resubmit a line from the history, and it is a duplicate, it is not entered into the history. The position then doesn't advance to the next historic line. * linenoise/linenoise.c (lino_hist_add): Do add the line even if it is duplicate if the last submitted line was from the middle of the history.
* linenoise: bugfix: handle ESC in extended command.Kaz Kylheku2016-09-301-1/+2
| | | | | | | | | | | | If the user types Ctrl-X and then an arrow key, we don't want garbage. We let an ESC received in Ctrl-X extended command mode to be processed normally and cancel that mode. * linenoise.c (edit): Bypass the extended command switch if the character is ESC. Then down below in the ESC case of the regular command switch, clear extended mode.
* linenoise: use USERPROFILE for home dir on Cygnal.Kaz Kylheku2016-09-171-1/+18
| | | | | | | * linenoise/linenoise.c (get_home): New static function. (edit_in_editor): Call get_home instead of getenv("HOME").
* linenoise: support inclusive selection.Kaz Kylheku2016-05-192-3/+23
| | | | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New mode flag, selinclusive. (lino_set_selinclusive, lino_get_selinclusive): New functions. (sync_data_to_buf): Adjust rightmost endpoint when selection is reversed and inclusive mode is in effect, so that the included character will be visually highlighted. (yank_sel, delete_sel): Adjust endpoint of selection if in in inclusive mode. * linenoise/linenoise.h (lino_set_selinclusive, lino_get_selinclusive): Declared.
* linenoise: g++ signed/unsigned warnings.Kaz Kylheku2016-04-201-4/+5
| | | | | | | | * linenoise/linenoise.c (free_completions): Use size_t for iterating over completions vector. (complete_line): Likewise. (edit_insert, edit_insert_str): Cast size_t value to int before comparing with l->dlen.
* linenoise: replace poor uses of size_t with int.Kaz Kylheku2016-03-291-76/+75
| | | | | | | | | | | | | | | | | | | * linenoise/linenoise.c (struct lino_state): Members plen, pos, sel, end, dlen, dpos, dsel, dend, cols, oldrow and maxrows change from size_t to int. (struct lino_undo): Member dpos changes likewise. (restore_undo, free_completions, complete_line, next_hist_match, history_search, sync_data_to_buf, copy_display_params, refresh_singleline, screen_rows, col_offset_in_str, refresh_multiline, scan_match_rev, scan_rev, scan_match_fwd, scan_fwd, find_nearest_paren, paren_jump, update_sel, yank_sel, delete_sel, edit_insert, edit_insert_str, edit_move_eol, edit_move_matching_paren, edit_delete_prev_all, edit_delete_to_eol, edit_delete_prev_word, edit_delete_line, edit): Replace various size_t's in function arguments, return values and local variables with int. Drop what would now be useless casts of constants to type int.
* Replace all stray C style casts with macros.Kaz Kylheku2016-03-291-33/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (gc_report_copies): C style casts found in this function. * linenoise.c (strip_qual, convert, coerce): Copy and paste the macros here. (record_undo, compare_completions, lino_add_completion, history_search, ab_append, sync_data_to_buf, refresh_singleline, screen_rows, refresh_multiline, find_nearest_paren, paren_jump, yank_sel, edit_move_matching_paren, edit, lino_make, lino_copy, lino_hist_add, lino_hist_set_max_len): C style casts replaced. * mpi/mpi-types.h (MP_DIGIT_BIT, MP_DIGIT_MAX, MP_WORD_BIT, MP_WORD_MAX, RADIX): C style casts replaced. * mpi/mpi.c (convert, coerce): Copy and paste the macros here. (mp_init_size, mp_init_copy, mp_copy, mp_set_int, mp_div_d, mp_bit, mp_to_double, mp_to_signed_bin, mp_to_unsigned_bin, mp_to_unsigned_buf, mp_toradix_case, mp_grow, s_mp_set_bit, s_mp_mod_2d, s_mp_mul_2d, s_mp_div_2d, s_mp_mul_d, s_mp_mul, s_mp_sqr, s_mp_div, s_mp_2expt, s_mp_todigit): C style casts replaced. * mpi/mplogic (convert): Macro copy and pasted here. (mpl_num_set, mpl_num_clear): C style casts replaced. * parser.c (provide_completions): Likewise. * signal.c (small_sigfillset): Likewise. * stream.c (stdio_truncate, test_set_indent_mode, set_indent_mode): Likewise.
* Header file cleanup.Kaz Kylheku2016-01-221-3/+0
| | | | | | | * arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c, hash.c, linenoise/linenoise.c, lisplib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Remove unncessary header files.
* Copyright year bump.Kaz Kylheku2015-12-313-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* linenoise: submit and stay in history.Kaz Kylheku2015-12-311-0/+19
| | | | | | | | | | * linenoise/linenoise.c (struct lino_state): New member save_hist_idx. (edit): If save_hist_idx is set, jump to that history position and clear it. Handle ENTER in extended (Ctrl-X) mode similarly to regular ENTER, but setting save_hist_idx. * txr.1: Documented.
* linenoise: bugfix: Ctrl-X bails out of hist searchKaz Kylheku2015-12-311-1/+1
| | | | | | | * linenoise/linenoise.c (history_search): Add CTL('X') to set of characters which terminate search and are processed again in the main editing function, so that Ctrl-X commands work in search.
* linenoise: substring flag in completion callback.Kaz Kylheku2015-10-032-4/+8
| | | | | | | | | | | | | | | | | | | 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: Ctrl-X/Ctrl-[AWR] relative to hist pos.Kaz Kylheku2015-10-021-6/+9
| | | | | | | | | | * 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: insert previous line command.Kaz Kylheku2015-10-021-0/+14
| | | | | | | * linenoise/linenoise.c (edit): Extended Ctrl-X Ctrl-R/r command added. * txr.1: Documented.
* linenoise: Ctrl-A/E overloaded in multi-line mode.Kaz Kylheku2015-10-011-1/+4
| | | | | | | | | | | | | * 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.