fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 62fdf0f7233e2322329430493518cff9e6007b9e parent 0a4eac4c4a7c66a717c0f7d1864d05fc34f58a5b Author: John Hawthorn <john.hawthorn@gmail.com> Date: Sun, 19 Jun 2016 23:36:39 -0700 Return exit code from run Diffstat:
| M | src/fzy.c | | | 6 | ++++-- |
| M | src/tty_interface.c | | | 6 | ++++-- |
| M | src/tty_interface.h | | | 4 | +++- |
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/fzy.c b/src/fzy.c @@ -13,6 +13,8 @@ #include "../config.h" int main(int argc, char *argv[]) { + int ret = 0; + options_t options; options_parse(&options, argc, argv); @@ -47,10 +49,10 @@ int main(int argc, char *argv[]) { tty_interface_t tty_interface; tty_interface_init(&tty_interface, &tty, &choices, &options); - tty_interface_run(&tty_interface); + ret = tty_interface_run(&tty_interface); } choices_destroy(&choices); - return 0; + return ret; } diff --git a/src/tty_interface.c b/src/tty_interface.c @@ -113,7 +113,7 @@ void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, strncpy(state->search, options->init_search, SEARCH_SIZE_MAX); } -void tty_interface_run(tty_interface_t *state) { +int tty_interface_run(tty_interface_t *state) { tty_t *tty = state->tty; choices_t *choices = state->choices; char *search = state->search; @@ -164,7 +164,7 @@ void tty_interface_run(tty_interface_t *state) { emit(state); /* Return to eventually exit successfully */ - return; + return 0; } else if (ch == KEY_ESC) { /* ESC */ ch = tty_getchar(tty); if (ch == '[' || ch == 'O') { @@ -177,4 +177,6 @@ void tty_interface_run(tty_interface_t *state) { } } } while (1); + + return 0; } diff --git a/src/tty_interface.h b/src/tty_interface.h @@ -13,9 +13,11 @@ typedef struct { options_t *options; char search[SEARCH_SIZE_MAX + 1]; + + int exit; } tty_interface_t; void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, options_t *options); -void tty_interface_run(tty_interface_t *state); +int tty_interface_run(tty_interface_t *state); #endif