zygo

ncurses gopher client
Log | Files | Refs

commit 2e03e83edc9dfc6aa0575bc2e43adc6632948c88
parent df9aa74cdaf17635c431dcb5caf92007bc413ca4
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 16 Jul 2022 11:42:56 +0100

Custom start page

Diffstat:
M.config.hhvn.h | 5+++++
Mconfig.def.h | 11+++++++++++
Mzygo.c | 11++---------
Mzygo.h | 3+++
4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/.config.hhvn.h b/.config.hhvn.h @@ -15,6 +15,11 @@ static short arg_pair[2] = {-1, 0}; static short err_pair[2] = {160, 0}; static short eid_pair[2] = {4, -1}; +static Elem start_page[] = { + LINK('1', "hhvn.uk", "", "hhvn.uk", "70"), + LINK('1', "hlirc.net", "", "hlirc.net", "70"), +}; + enum Bindings { BIND_URI = ':', BIND_DISPLAY = '+', diff --git a/config.def.h b/config.def.h @@ -15,6 +15,17 @@ static short arg_pair[2] = {-1, 0}; static short err_pair[2] = {160, 0}; static short eid_pair[2] = {4, -1}; +/* Page shown if zygo is called without any arguments. + * This can contain anything you want, really. + * + * The convenience macros INFO() and LINK() are in zygo.h */ +static Elem start_page[] = { + INFO("Welcome to zygo."), + LINK('1', " - git repo", "/git/o/zygo", "hhvn.uk", "70"), + INFO(""), + INFO("Type 'h' to read the man page."), +}; + /* Some bindings are still hardcoded in zygo.c */ enum Bindings { BIND_URI = ':', diff --git a/zygo.c b/zygo.c @@ -1179,13 +1179,6 @@ main(int argc, char *argv[]) { Elem err = {0, 0, NULL, NULL, NULL, NULL, 0}; char *s; int i; - Elem start[] = { - {0, 'i', "Welcome to zygo."}, - {0, '1', " - git repo", "/git/o/zygo", "hhvn.uk", "70"}, - {0, 'i', ""}, - {0, 'i', "Type 'h' to read the man page."}, - {0, 'i', NULL}, - }; for (i = 1; i < argc; i++) { if ((*argv[i] == '-' && *(argv[i]+1) == '\0') || @@ -1252,8 +1245,8 @@ main(int argc, char *argv[]) { list_append(&page, &err); } - for (i = 0; start[i].desc; i++) - list_append(&page, &start[i]); + for (i = 0; i < sizeof(start_page) / sizeof(start_page[0]); i++) + list_append(&page, &start_page[i]); } setlocale(LC_ALL, ""); diff --git a/zygo.h b/zygo.h @@ -19,6 +19,9 @@ #define BUFLEN 2048 #define zygo_assert(expr) (expr ? ((void)0) : (endwin(), assert(expr))) +#define INFO(desc) {0, 'i', desc, NULL, NULL, NULL} +#define LINK(type, desc, selector, server, port) \ + {0, type, desc, selector, server, port} typedef struct Elem Elem; struct Elem {