cgmnlm

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/cgmnlm.git
Log | Files | Refs | README | LICENSE

commit d84ee77e249eae11c4b240294c6d37851f1ba11f
parent 90995e834f2e87427f2f4bddf26a93258b45aa31
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue, 29 Sep 2020 13:19:18 -0400

gmnlm: add -W option

Diffstat:
Mdoc/gmnlm.scd | 5++++-
Msrc/gmnlm.c | 9++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/doc/gmnlm.scd b/doc/gmnlm.scd @@ -6,7 +6,7 @@ gmnlm - Gemini line-mode browser # SYNPOSIS -*gmnlm* [-PU] [-j _mode_] _gemini://..._ +*gmnlm* [-PU] [-j _mode_] [-W _width_] _gemini://..._ # DESCRIPTION @@ -25,3 +25,6 @@ gmnlm - Gemini line-mode browser *-U* Disable conservative use of Unicode symbols to render Gemini layout features. + +*-W* _width_ + Sets the maximum width, in columns, of Gemtext pages. diff --git a/src/gmnlm.c b/src/gmnlm.c @@ -30,6 +30,7 @@ struct history { struct browser { bool pagination, unicode; + int max_width; struct gemini_options opts; struct gemini_tofu tofu; enum tofu_action tofu_mode; @@ -473,6 +474,9 @@ display_gemini(struct browser *browser, struct gemini_response *resp) struct winsize ws; ioctl(fileno(browser->tty), TIOCGWINSZ, &ws); + if (browser->max_width != 0 && ws.ws_col > browser->max_width) { + ws.ws_col = browser->max_width; + } FILE *out = browser->tty; bool searching = browser->searching; @@ -930,7 +934,7 @@ main(int argc, char *argv[]) }; int c; - while ((c = getopt(argc, argv, "hj:PU")) != -1) { + while ((c = getopt(argc, argv, "hj:PUW:")) != -1) { switch (c) { case 'h': usage(argv[0]); @@ -953,6 +957,9 @@ main(int argc, char *argv[]) case 'U': browser.unicode = false; break; + case 'W': + browser.max_width = strtoul(optarg, NULL, 10); + break; default: fprintf(stderr, "fatal: unknown flag %c\n", c); curl_url_cleanup(browser.url);