commit d0acd0f4d08a0d5e8f6c729f53de2f381b270202
parent 84df94447cdb081ec305a5ba9d2b0ef89dd34fc3
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 20 Sep 2020 20:11:48 -0400
Add reduced-unicode mode
Diffstat:
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/gmnlm.c b/src/gmnlm.c
@@ -23,7 +23,7 @@ struct history {
};
struct browser {
- bool pagination;
+ bool pagination, unicode;
struct gemini_options opts;
FILE *tty;
@@ -184,13 +184,13 @@ display_gemini(struct browser *browser, struct gemini_response *resp)
trim_ws(tok.heading.title));
break;
case GEMINI_LIST_ITEM:
- // TODO: Option to disable Unicode
- col += fprintf(browser->tty, " • %s\n",
+ col += fprintf(browser->tty, " %s %s\n",
+ browser->unicode ? "•" : "*",
trim_ws(tok.list_item));
break;
case GEMINI_QUOTE:
- // TODO: Option to disable Unicode
- col += fprintf(browser->tty, " | %s\n",
+ col += fprintf(browser->tty, " %s %s\n",
+ browser->unicode ? "|" : "|",
trim_ws(tok.quote_text));
break;
}
@@ -368,19 +368,23 @@ main(int argc, char *argv[])
{
struct browser browser = {
.pagination = true,
+ .unicode = true,
.url = curl_url(),
.tty = fopen("/dev/tty", "w+"),
};
int c;
- while ((c = getopt(argc, argv, "hP")) != -1) {
+ while ((c = getopt(argc, argv, "hPU")) != -1) {
switch (c) {
- case 'P':
- browser.pagination = false;
- break;
case 'h':
usage(argv[0]);
return 0;
+ case 'P':
+ browser.pagination = false;
+ break;
+ case 'U':
+ browser.unicode = false;
+ break;
default:
fprintf(stderr, "fatal: unknown flag %c\n", c);
return 1;