diff --git a/src/gmnlm.c b/src/gmnlm.c

index 2e41647b33eae2d177efdf4d329502bfe04c4df6..fd029df79d8bef568492a3b3de9f8672dc794fc6 100644

--- a/src/gmnlm.c

+++ b/src/gmnlm.c

@@ -1100,12 +1100,40 @@ char *text = NULL;

int row = 0, col = 0;

struct gemini_token tok;

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;

+ char prompt[4096];

+ char *end = NULL;

+ int info_rows = 0;

+ bool first_screen = 1;

while (text != NULL || gemini_parser_next(&p, &tok) == 0) {

repeat:

+ if (!row) {

+ if (browser->meta && (end = strchr(resp->meta, ';')) != NULL) {

+ *end = 0;

+ }

+ snprintf(prompt, sizeof(prompt), "\n%s at %s\n"

+ "[Enter]: read more; %s[N]: =follow Nth link; %s%s[q]uit; [?]; or type a URL\n"

+ "(more) => ", resp->meta, browser->plain_url,

+ browser->searching ? "[n]ext result; " : "",

+ browser->history->prev ? "[b]ack; " : "",

+ browser->history->next ? "[f]orward; " : "");

+ if (end != NULL) {

+ *end = ';';

+ }

+

+ info_rows = 0;

+ for (char *ln = prompt; (end = strchr(ln, '\n')); ln = end + 1) {

+ *end = '\0';

+ int len = strlen(ln);

+ info_rows += len / ws.ws_col + (len % ws.ws_col != 0);

+ if (!*ln) info_rows++; // empty line

+ *end = '\n';

+ }

+ // if not first screen, text is preceded by an empty line,

+ // and help text is followed by a prompt line

+ info_rows += !first_screen + 1;

+ }

+

switch (tok.token) {

case GEMINI_TEXT:

col += fprintf(out, " ");

@@ -1218,20 +1246,7 @@ fprintf(out, ANSI_COLOR_RESET);

++row; col = 0;

if (browser->pagination && row >= ws.ws_row - info_rows) {

- char prompt[4096];

- char *end = NULL;

- if (browser->meta && (end = strchr(resp->meta, ';')) != NULL) {

- *end = 0;

- }

- snprintf(prompt, sizeof(prompt), "%s at %s\n"

- "[Enter]: read more; %s[N]: follow Nth link; %s%s[q]uit; [?]; or type a URL\n"

- "(more) => ", resp->meta, browser->plain_url,

- browser->searching ? "[n]ext result; " : "",

- browser->history->prev ? "[b]ack; " : "",

- browser->history->next ? "[f]orward; " : "");

- if (end != NULL) {

- *end = ';';

- }

+ first_screen = 0;

enum prompt_result result = PROMPT_AGAIN;

while (result == PROMPT_AGAIN) {

result = do_prompts(prompt, browser);