zygo

ncurses gopher client
Log | Files | Refs

commit 10f6add1458ce69ad6d87ae2c21e06a97b53fde6
parent 1ba0f8466f75b2b27b1feb97956cd75698c4f1d7
Author: hhvn <dev@hhvn.uk>
Date:   Mon, 17 Jan 2022 13:37:18 +0000

zygo.c: error if current needed

Diffstat:
Mzygo.c | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/zygo.c b/zygo.c @@ -747,6 +747,12 @@ run(void) { draw_page(); draw_bar(); +#define checkcurrent() \ + if (!current || !current->server || !current->port) { \ + error("%c command can only be used on remote gopher menus", c); \ + break; \ + } + /* get_wch does refresh() for us */ while ((ret = get_wch(&c)) != ERR) { if (!ui.candraw || ui.error) { @@ -846,10 +852,6 @@ run(void) { } draw_bar(); } else { - /* Restrict keys for starting menu */ - if (!current && !(isdigit((int)c) || c == ':' || c == 'h' || c == 'q')) - continue; - switch (c) { case KEY_DOWN: case 'j': @@ -894,6 +896,7 @@ run(void) { } break; case '*': + checkcurrent(); go(current, 0); draw_page(); break; @@ -912,6 +915,7 @@ run(void) { draw_page(); break; case 'r': + checkcurrent(); e = elem_dup(current); free(e->selector); e->selector = strdup(""); @@ -940,6 +944,8 @@ run(void) { case '+': case '/': case 'a': + if (c == 'a' || c == '+') + checkcurrent(); ui.cmd = (char)c; ui.wantinput = 1; ui.input[0] = '\0'; @@ -968,6 +974,8 @@ gonum: draw_page(); draw_bar(); } + +#undef checkcurrent } void