summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-04 22:09:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-04 22:09:43 -0700
commitedbb612c40e3541a170aeaaf41ad8703c8b70cf9 (patch)
treedec1033f820f12de39ffea15f095e40aff706333 /parser.c
parent875c3401a17f9264b83f5dd9c673cac1ca837e1a (diff)
downloadtxr-edbb612c40e3541a170aeaaf41ad8703c8b70cf9.tar.gz
txr-edbb612c40e3541a170aeaaf41ad8703c8b70cf9.tar.bz2
txr-edbb612c40e3541a170aeaaf41ad8703c8b70cf9.zip
linenoise: get rid of globals; everything in struct.
* 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.
Diffstat (limited to 'parser.c')
0 files changed, 0 insertions, 0 deletions