1
0
mirror of https://git.sr.ht/~sircmpwn/gmni synced 2024-11-23 04:51:59 +01:00

gmnlm: Improve paging behavior on narrow terminals

This commit is contained in:
Zach DeCook 2021-04-02 09:31:00 -04:00 committed by Drew DeVault
parent 77b73efbcd
commit a348eb906d

@ -845,6 +845,10 @@ display_gemini(struct browser *browser, struct gemini_response *resp)
int row = 0, col = 0; int row = 0, col = 0;
struct gemini_token tok; struct gemini_token tok;
struct link **next = &browser->links; struct link **next = &browser->links;
// When your screen is too narrow, more lines will be used for helptext and URL.
// 87 is the maximum width of the prompt.
int info_rows = (ws.ws_col >= 87) ? 4 : 6;
while (text != NULL || gemini_parser_next(&p, &tok) == 0) { while (text != NULL || gemini_parser_next(&p, &tok) == 0) {
repeat: repeat:
switch (tok.token) { switch (tok.token) {
@ -933,7 +937,7 @@ repeat:
if (text) { if (text) {
int w = wrap(out, text, &ws, &row, &col); int w = wrap(out, text, &ws, &row, &col);
text += w; text += w;
if (text[0] && row < ws.ws_row - 4) { if (text[0] && row < ws.ws_row - info_rows) {
continue; continue;
} }
@ -951,7 +955,7 @@ repeat:
} }
++row; col = 0; ++row; col = 0;
if (browser->pagination && row >= ws.ws_row - 4) { if (browser->pagination && row >= ws.ws_row - info_rows) {
char prompt[4096]; char prompt[4096];
char *end = NULL; char *end = NULL;
if (browser->meta && (end = strchr(resp->meta, ';')) != NULL) { if (browser->meta && (end = strchr(resp->meta, ';')) != NULL) {