summaryrefslogtreecommitdiffstats
path: root/linenoise
Commit message (Collapse)AuthorAgeFilesLines
...
* linenoise: get rid of globals; everything in struct.Kaz Kylheku2015-09-043-182/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Bringing in Linenoise example.Kaz Kylheku2015-09-041-0/+75
| | | | * linenoise/example.c: New file.
* linenoise: tty read fix.Kaz Kylheku2015-09-041-1/+2
| | | | | | * 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.
* Null out freed history elements.Kaz Kylheku2015-09-041-7/+15
| | | | | | | | | | * 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: change naming to conform to project.Kaz Kylheku2015-09-042-146/+145
| | | | | | | | 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.
* Eliminate tabs from linenoise source.Kaz Kylheku2015-09-041-19/+19
| | | | | | * linenoise/linenoise.c (enum KEY_ACTION): Remove tabs from declaration. This is the only place in the file which has tabs.
* linenoise: compile as C++ and use checked allocator.Kaz Kylheku2015-09-042-27/+19
| | | | | | | | | | | | | | | | | * 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++.
* Compile and link linkenoise into txr; fix errors.Kaz Kylheku2015-09-041-9/+9
| | | | | | | | | | | * 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.
* Add linenoise library.Kaz Kylheku2015-09-033-0/+1200
* LICENSE: Add Linenoise authors to the list of copyright holders. * linenoise/LICENSE: New file. * linenoise/linenoise.c: New file. * linenoise/linenoise.h: New file.