From 12bd59c5ad9f437f1555dd22b1a792c6d4ce490a Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sun, 19 Jun 2016 23:17:53 -0700 Subject: Store state in tty_interface_t --- src/tty_interface.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/tty_interface.c') diff --git a/src/tty_interface.c b/src/tty_interface.c index 69c3ab1..38b0dc0 100644 --- a/src/tty_interface.c +++ b/src/tty_interface.c @@ -94,9 +94,20 @@ static void emit(choices_t *choices) { #define KEY_DEL 127 #define KEY_ESC 27 -void tty_interface_run(tty_t *tty, choices_t *choices, options_t *options) { +void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, options_t *options) { + state->tty = tty; + state->choices = choices; + state->options = options; + if (options->init_search) - strncpy(search, options->init_search, SEARCH_SIZE_MAX); + strncpy(state->search, options->init_search, SEARCH_SIZE_MAX); +} + +void tty_interface_run(tty_interface_t *state) { + tty_t *tty = state->tty; + choices_t *choices = state->choices; + options_t *options = state->options; + char *search = state->search; choices_search(choices, search); char ch; -- cgit v1.2.3