diff options
Diffstat (limited to 'src/cli.c')
| -rw-r--r-- | src/cli.c | 33 |
1 files changed, 14 insertions, 19 deletions
@@ -18,19 +18,27 @@ cli_display_calc(int x, int y) int cli_read_input(void) { - char *txt = readline(""); + char *txt = readline(NULL); - if ((!txt) || (txt[0] == '\0')) { + if (!txt) + { return DISP_QUIT; } - else if (txt[0] == 'q') { + else if (txt[0] == '\0') + { free(txt); return DISP_QUIT; } -#ifndef NDEBUG - if ((*txt == 'r') || (*txt == 'g')) + else if (txt[0] == 'q') + { + free(txt); + return DISP_QUIT; + } + else if ((txt[0] == 'r') || (txt[0] == 'g')) + { + free(txt); return DISP_RELOAD; -#endif + } int res = atoi(txt); free(txt); @@ -45,18 +53,5 @@ cli_display_res(bool ok, int ms) void cli_destroy(void) {} -#ifndef NDEBUG void *cli_pre_reload(void) {return NULL;} void cli_post_reload(void *) {} -#endif - -#ifdef NDEBUG -static struct disp __cli_disp = { - .init = cli_init, - .display_calc = cli_display_calc, - .read_input = cli_read_input, - .display_res = cli_display_res, - .destroy = cli_destroy -}; -struct disp *cli_disp = &__cli_disp; -#endif |
