| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.c (complete_line, sync_data_to_buf,
refresh_singleline, refresh_multiline, refresh_line,
edit_insert, edit_move_left, edit_move_right, edit_move_home,
edit_move_end, edit_history_next, edit_delete, edit_backspace,
edit_delete_prev_word): struct lino_state replaced
with lino_t.
|
|
|
|
|
| |
* linenoise/linenoise.c (complete_line): Use
TAB and ESC instead of 9 and 27.
|
|
|
|
|
|
| |
* linenoise/linenoise.c (enum key_action): New enum
constant, CTRL_V.
(edit): Implement Ctrl-V.
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (enum key_action): Unused KEY_NULL
removed. Removed uninformative comments next to
self-explanatory enum constants.
(edit): Removed uninformative comments next to cases
based on enum key_action enum constants.
Replaced 8 with CTRL_H.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The linenoise edit buffer now shows a printed representation
of underlying data. In this printed representation, multiple
characters can denote a single physical character, so that
a control code like 15 can be displayed as ^M.
In the future, this will help with a Unicode-ization of
linenoise.
The actual edit routines now operate on the data array
rather than buf, and the new function sync_data_to_buf is used
to synchronize buf with data for the sake of refreshing the
display.
* linenoise/linenoise.c (LINENOISE_MAX_DISP): New variable.
(struct lino_state): buf member becomes an array, so the
display buffer is now in the structure, and not stack
allocated in the linenoise function. New members data,
dlen and dpos for tracking the underlying data.
Also, the buflen member variable is gone. Uses of buflen
are replaced with sizeof.
(sync_data_to_buf): New static function.
(complete_line): Pass ls->data to callback, rather than
ls->buf. In the saving and restoring trick used when
displaying completions, we must copy in the completion to the
data array; we cannot swizzle a buffer pointer like before.
The restoration of the state is simplified; just copy back
the entire original. Lastly, when a completion is selected,
it must go into the data array, and not buf. Here, there
is a bugfix; it appears that refresh_line was not called;
I had to add that call. (Did that work before this change?)
(refresh_line): Call sync_data_to_buf before calling either
refresh function.
(edit_insert, edit_move_left, edit_move_right, edit_move_home,
edit_move_end, edit_history_next, edit_backspace,
edit_delete_prev_word): Operate on data array, dlen and dpos
rather than buf, len and pos.
(edit): Doesn't take buffer and length parameters any more.
No need to initialize context structure members buf, or
removed member buflen. New members dlen and dpos have to be
initialized. Inlined edit operations now work with data array,
rather than buf.
(go_raw): Buffer and buflen arguments are gone. Non-tty code
still allocates buffer on stack, but only in its local block.
(linenoise): Do not instantiate local buffer for passing
to go_raw, which doesn't take one any more.
When finished, duplicate the string in the data array.
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (generate_beep): Take line noise
context argument and send BEL character to output file
descriptor, rather than hardcoding to stderr.
(complete_line): Pass context to generate_beep.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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/example.c: New file.
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): If 0 bytes is read from the
tty for any reason, return -1 so that the linenoise function
will return a null pointer rather than a blank line.
|
|
|
|
|
|
|
|
|
|
| |
* linenoise/linenoise.c (edit): Set freed element of history
array to null.
(free_hist): Null out all elements, and then the array
pointer.
(lino_hist_set_max_len): Calculate value of history_len
variable in obviously correct way, based on amount of history
preserved.
|
|
|
|
|
|
|
|
| |
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 (enum KEY_ACTION):
Remove tabs from declaration. This is the only
place in the file which has tabs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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++.
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile (OBJS): Add linenoise/linenoise.o.
* linenoise/linenoise.c (linenoiseEditInsert,
linenoiseEditMoveLeft, linenoiseEditMoveRight,
linenoiseEditMoveEnd, linenoiseEditHistoryNext,
linenoiseEditDelete, linenoiseEditBackspace,
linenoiseEditDeletePrevWord): These de facto internal
functions are switched from external to static.
|
|
* LICENSE: Add Linenoise authors to the list of copyright holders.
* linenoise/LICENSE: New file.
* linenoise/linenoise.c: New file.
* linenoise/linenoise.h: New file.
|