commit be4cf45ab573094b233e2adaf6be08a7c85cf8bb
parent 1971f9c99a3d9ee1370e5e841ddf433997ae3856
Author: hhvn <dev@hhvn.uk>
Date: Sun, 16 Jan 2022 21:00:02 +0000
zygo.c zygo.h config.def.h: scheming
Diffstat:
3 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -1,4 +1,4 @@
-static char *starturi = "gopher://hhvn.uk";
+static char *starturi = "gopher://hhvn.uk/1/git/o/zygo";
static char *plumber = "xdg-open";
static int parallelplumb = 0;
static int stimeout = 5;
@@ -14,24 +14,25 @@ static Scheme scheme[] = {
/* type, name, fg */
{'i', " ", -1 },
{'0', "Text", -1 },
- {'1', "Dir ", -1 },
- {'2', "CCSO", -1 },
- {'4', "Bin ", -1 },
- {'5', "Bin ", -1 },
- {'9', "Bin ", -1 },
- {'7', "Srch", -1 },
- {'8', "Teln", -1 },
- {'T', "Teln", -1 },
- {'+', "Alt ", -1 },
- {'I', "Img ", -1 },
- {'g', "Img ", -1 },
- {'h', "HTML", -1 },
- {'s', "Snd ", -1 },
- {'d', "Doc ", -1 },
- {'3', "ERR ", -1 },
+ {'1', "Dir ", 2 },
+ {'2', "CCSO", 3 },
+ {'4', "Bin ", 4 },
+ {'5', "Bin ", 4 },
+ {'9', "Bin ", 4 },
+ {'7', "Srch", 3 },
+ {'8', "Teln", 5 },
+ {'T', "Teln", 5 },
+ {'+', "Alt ", 5 },
+ {'I', "Img ", 6 },
+ {'g', "Img ", 6 },
+ {'h', "HTML", 5 },
+ {EXTR, "Extr", 5 },
+ {'s', "Snd ", 7 },
+ {'d', "Doc ", 8 },
+ {'3', "ERR ", 1 },
/* DNE! These values are actually used:
* -1 = default foregrounds
* 0 = default colour pair */
- {'\0', NULL, -1, 0 },
+ {'\0', "????", 1 },
};
diff --git a/zygo.c b/zygo.c
@@ -328,7 +328,7 @@ list_append(List **l, Elem *e) {
}
elem = elem_dup(e);
- if (elem->type != 'i')
+ if (elem->type != 'i' && elem->type != '3')
elem->id = ++(*l)->lastid;
if (!(*l)->elems) {
@@ -523,9 +523,14 @@ error(char *format, ...) {
}
Scheme *
-getscheme(char type) {
+getscheme(Elem *e) {
+ char type;
int i;
+ type = e->type;
+ if (type == 'h' && strstr(e->selector, "URL:"))
+ type = EXTR;
+
for (i = 0; ; i++)
if (scheme[i].type == type || scheme[i].type == '\0')
return &scheme[i];
@@ -536,15 +541,15 @@ draw_line(Elem *e, int maxlines) {
int lc, cc;
attron(COLOR_PAIR(PAIR_EID));
- if (e->type != 'i')
+ if (e->type != 'i' && e->type != '3')
printw("% 3d ", e->id);
else
printw(" ");
attroff(A_COLOR);
- printw("%s | ", getscheme(e->type)->name);
- attron(COLOR_PAIR(getscheme(e->type)->pair));
- printw("%s\n", e->desc);
+ attron(COLOR_PAIR(getscheme(e)->pair));
+ printw("%s ", getscheme(e)->name);
attroff(A_COLOR);
+ printw("| %s\n", e->desc);
return 1;
}
@@ -820,7 +825,7 @@ main(int argc, char *argv[]) {
init_pair(PAIR_ARG, arg_pair[0], arg_pair[1]);
init_pair(PAIR_ERR, err_pair[0], err_pair[1]);
init_pair(PAIR_EID, eid_pair[0], eid_pair[1]);
- for (i = 0; scheme[i].type; i++) {
+ for (i = 0; i == 0 || scheme[i - 1].type; i++) {
scheme[i].pair = i + PAIR_SCHEME;
init_pair(scheme[i].pair, scheme[i].fg, -1);
}
diff --git a/zygo.h b/zygo.h
@@ -40,6 +40,7 @@ struct List {
size_t lastid;
};
+enum { EXTR = 1 };
typedef struct Scheme Scheme;
struct Scheme {
char type;
@@ -99,7 +100,7 @@ int net_close(void);
/* UI functions */
void error(char *format, ...);
-Scheme *getscheme(char type);
+Scheme *getscheme(Elem *e);
int draw_line(Elem *e, int maxlines);
void draw_page(void);
void draw_bar(void);