| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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/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/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/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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 (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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 (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 (link_into_list, unlink_from_list):
New static functions.
(lino_make): Use link_into_list instead of open-coded
list manipulation.
(lino_copy): New function.
(lino_free): Use unlink_from list instead of
open-coded list manipulation.
* linenoise/linenoise.h (lino_copy): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is unused code which just addds to the executable size.
Also it passes a char to isprint, which is undefined behavior
if that char happens to be negative.
* linenoise/example.c (main): Remove --keycodes option
and reference to lino_print_keycodes function.
* linenoise/linenoise.c, linenoise/linenoise.h
(lino_print_keycodes): Function removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In this commit, we introduce a persistent error
variable stored in the lino_t structure, and
functions to access it.
* linenoise/linenoise.c (struct lino_state): New
member, error.
(enable_raw_mode): Don't set errno to ENOTTY;
set linenoise error to lino_notty.
(complete_line, edit, go_raw, linenoise, lino_hist_save,
lino_hist_load): Set linenoise error before returning -1.
(lino_get_error, lino_set_error): New functions.
* linenoise/linenoise.h (enum lino_error, lino_error_t):
New enum.
(lino_get_error, lino_set_error): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (completion_callback, orig_termios,
rawmode, mlmode, history_max_len, history_len, history): Global
variables removed; moved into struct lino_state.
(struct lino_state): New members next, prev. New members
completion_callback, orig_termios, rawmode, mlmode,
history_max_len, history_len, history.
(lino_list): New static variable: dummy node for circular
list of struct lino_state structures.
(lino_set_multiline): Operate on structure rather than global
variable.
(enable_raw_mode, disable_raw_mode): Operate on structure. Use
file descriptors from structures rather than inconsistent
hard-coded use of STDIN_FILENO and the argument fd, which is
gone.
(lino_clear_screen): Obtain file descriptor from structure,
rather than global.
(complete_line): Operate on structure rather than globals.
Pass context to completion callback.
(lino_set_completion_cb): Store callback in structure rather
than global. Store new context argument also.
(reresh_line): Take mode from structure rather than global.
(edit_insert, edit_move_end): Operate on struture rather
than globals.
(edit): Do not accept file descriptor arguments.
Do not update ifd and ofd members of structure; just rely on these
values to already be there, since the lino_make constructor
puts them there.
(lino_print_keycodes, go_raw): Operate on structure.
(lino_make, lino_free): New functions.
(lino_cleanup): New static function.
(linenoise, free_hist): Operate on structure.
(atexit_handler): Loop over all structures in global list,
and clean up each one.
(lino_hist_add, lino_list_set_max_len, lino_hist_save,
lino_hist_load): Operate on structure.
* linenoise/linenoise.h (lino_t): New typedef.
(lino_compl_cb_t): Function type takes new context argument.
(lino_set_completion_cb, linenoise, lino_hist_add,
lino_hist_set_max, lino_his_save, lino_hist_load,
lino_clear_screen, lino_set_multiline,
lino_print_keycodes): Declarations updated.
* linenoise/example.c (completion): Take new context argument,
and ignore it.
(main): Create linenoise context with lino_make, giving it
the input and output file descriptor, and pass it to all functions.
|
|
|
|
|
|
|
|
| |
linenoise/linenoise.c, linenoise/linenoise.h: Renaming
all camel-case identifiers to underscores. The
verbose linenoise prefix becomes lino_.
All caps enum tag gets lower cased.
Static functions with linenoise prefix lose the prefix.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (mem_t): New typedef, compatible
with the one in lib.h, which we don't want to include.
(chk_malloc, chk_realloc): External declarations added.
(unsupported_term): Make element type const char *.
(linenoiseAddCompletion): Use checked allocator, add
casts, use the superior "sizeof *dest_pointer_var"
expression in size calculations rather than
"sizeof (maybe_wrong_type)".
(abAppend, linenoiseHistoryAdd, linenoiseHistorySetMaxLen): Likewise.
* linenoise/linenoise.h: Remove unnecessary include
guards; we don't use them in this project.
Remove 'extern "C"'; we don't require C linkage when
compiling everything as C++.
|
|
* LICENSE: Add Linenoise authors to the list of copyright holders.
* linenoise/LICENSE: New file.
* linenoise/linenoise.c: New file.
* linenoise/linenoise.h: New file.
|