zygo

ncurses gopher client
Log | Files | Refs

commit 9e691b8df377fa6f938c10c92a9f7eb704920614
parent e72231aa0936e74789f1d82726f4e444b17750fa
Author: hhvn <dev@hhvn.uk>
Date:   Wed,  9 Feb 2022 15:38:50 +0000

Add specific error to start message.

Diffstat:
Mzygo.c | 20+++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/zygo.c b/zygo.c @@ -1152,11 +1152,10 @@ usage(char *argv0) { int main(int argc, char *argv[]) { Elem *target = NULL; + Elem err = {0, 0, NULL, NULL, NULL, NULL, 0}; char *s; int i; Elem start[] = { - {0, '3', "No URI specified, or unable to locate URI."}, - {0, 'i', ""}, {0, 'i', "Welcome to zygo."}, {0, '1', " - git repo", "/git/o/zygo", "hhvn.uk", "70"}, {0, 'i', ""}, @@ -1164,9 +1163,6 @@ main(int argc, char *argv[]) { {0, 'i', NULL}, }; - for (i = 0; start[i].desc; i++) - list_append(&page, &start[i]); - for (i = 1; i < argc; i++) { if ((*argv[i] == '-' && *(argv[i]+1) == '\0') || (*argv[i] != '-' && target)) { @@ -1224,6 +1220,20 @@ main(int argc, char *argv[]) { } } + if (!page) { + if (ui.error) { + err.type = '3'; + err.desc = ui.errorbuf; + list_append(&page, &err); + err.type = 'i'; + err.desc = ""; + list_append(&page, &err); + } + + for (i = 0; start[i].desc; i++) + list_append(&page, &start[i]); + } + setlocale(LC_ALL, ""); initscr(); noecho();