diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-20 05:47:57 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-20 05:47:57 -0700 |
commit | 4aaf96f5aaab5c249c3c8ea6d24ee6683bca6f10 (patch) | |
tree | a55a4672b67612a05726e820ce9c99f5b8e6a503 /linenoise/linenoise.h | |
parent | f374abcd23a63f628a9ec7b84e2d797d3fc28342 (diff) | |
download | txr-4aaf96f5aaab5c249c3c8ea6d24ee6683bca6f10.tar.gz txr-4aaf96f5aaab5c249c3c8ea6d24ee6683bca6f10.tar.bz2 txr-4aaf96f5aaab5c249c3c8ea6d24ee6683bca6f10.zip |
listener: unbundle from termios.
This commit fixes the conceptual issue that when there is no termios
support (HAVE_TERMIOS is absent/false), then there is no
listener at all, even though the listener supports plain mode
that doesn't require termios.
* Makefile (linenoise/linenoise.o): Link in unconditionally,
not subject to have_termios.
* linenoise.c: Include termios-related header only if
HAVE_TERMIOS.
(struct lino_state): Define the completion_callback and
orig_termios members only if HAVE_TERMIOS.
(wcnsprintf, atexit_handler, enable_raw_mode,
disable_raw_mode, get_cursor_position, get_columns,
lino_clear_screen, refresh_line, handle_resize, generate_beep,
delete_undo, free_undo_stack, record_undo, record_triv_undo,
remove_noop_undo, restore_undo, undo_subst_hist_idx,
undo_renumber_hist_idx, free_completions, sync_data_to_buf,
compare_completions, complete_line, lino_set_completion_cb,
lino_add_completion, next_hist_match, copy_display_params,
history_search, ab_init, ab_append, ab_free, sync_data_to_buf,
copy_display_params, refresh_singleline, col_offset_in_str,
refresh_multiline, refresh_line, move_cursor_multiline,
move_cursor, scan_match_rev, scan_rev, scan_match_fwd,
scan_fwd, find_nearest_paren, usec_delay, paren_jump, flash,
yank, yank_by_ptr, update_sel, clear_sel, yank_sel,
delete_sel, edit_insert, edit_insert_str, edit_move_left,
edit_move_right, edit_move_home, edit_move_sol, edit_move_end,
edit_move_eol, edit_move_matching_paren, edit_history_next,
edit_delete, edit_backspace, edit_delete_prev_all,
edit_delete_to_eol, edit_delete_prev_word, edit_delete_line,
tr, char, edit_in_editor, edit, sigwinch_handler): Functions
defined only if HAVE_TERMIOS.
(struct abuf, struct row_values): Struct types defined only if
HAVE_TERMIOS.
(screen_rows): Defined only if HAVE_TERMIOS.
(linenoise): Support only noninteractive read loop unless
HAVE_TERMIOS.
(lino_make): If HAVE_TERMIOS is false, then set the
noninteractive flag, so the linenoise function enters
the plain-mode loop.
(lino_cleanup, lino_hist_add): Add #ifdefs to avoid calling
nonexistent functions when HAVE_TERMIOS is false.
* linenoise/linenoise.h (struct lino_completions,
lino_compl_cb_t): Define these types only if HAVE_TERMIOS.
(lino_set_completion_cb, lino_add_completion): Declare only if
HAVE_TERMIOS.
* parser.c: Include linenoise/linenoise.h unconditionally.
(report_security_problem, load_rcfile, repl_intr,
read_eval_ret_last, get_home_path, repl_warning,
is_balanced_line, hist_save): Now define regardless of
HAVE_TERMIOS.
(repl): Define regardless of HAVE_TERMIOS, but don't set
completion or atom callback if HAVE_TERMIOS is false.
* parser.h (repl): Declare unconditionally, not subject to
HAVE_TERMIOS.
* txr.c (if_termios): New macro.
(opt_noninteractive): Initialize to 1 if HAVE_TERMIOS is false.
(help): Text about entering into listener mode is always
present now, even in a build withou HAVE_TERMIOS.
(banner): Function is always defined. If we don't
HAVE_TERMIOS, then the unused string literal that will
never be printed is replaced by nil.
(hint): Function removed.
(txr_main): Blocks conditional on HAVE_TERMIOS that either
call banner and go to the repl, or else call hint and exit,
are reduced to unconditionally calling banner and going to the
repl. All #if HAVE_TERMIOS blocks are similarly replaced with
just the HAVE_TERMIOS case.
Diffstat (limited to 'linenoise/linenoise.h')
-rw-r--r-- | linenoise/linenoise.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/linenoise/linenoise.h b/linenoise/linenoise.h index 7fef68d9..bc72eaa7 100644 --- a/linenoise/linenoise.h +++ b/linenoise/linenoise.h @@ -92,6 +92,8 @@ typedef struct lino_os { wide_disp \ } +#if HAVE_TERMIOS + typedef struct lino_completions { size_t len; wchar_t **cvec; @@ -102,6 +104,8 @@ typedef void lino_compl_cb_t(const wchar_t *, lino_completions_t *, void *ctx); void lino_set_completion_cb(lino_t *, lino_compl_cb_t *, void *ctx); void lino_add_completion(lino_completions_t *, const wchar_t *); +#endif + void lino_init(lino_os_t *); lino_t *lino_make(mem_t *istream, mem_t *ostream); lino_t *lino_copy(lino_t *); |