mirror of
https://git.sr.ht/~sircmpwn/gmni
synced 2024-11-23 00:42:15 +01:00
jump more than one entry back or forth in history
by giving an optional number to b & f commands. The default behaviour of b & f commands has not been changed.
This commit is contained in:
parent
8796267c43
commit
529b1059af
37
src/gmnlm.c
37
src/gmnlm.c
@ -73,8 +73,8 @@ const char *help_msg =
|
|||||||
"q\tQuit\n"
|
"q\tQuit\n"
|
||||||
"N\tFollow Nth link (where N is a number)\n"
|
"N\tFollow Nth link (where N is a number)\n"
|
||||||
"p[N]\tShow URL of Nth link (where N is a number)\n"
|
"p[N]\tShow URL of Nth link (where N is a number)\n"
|
||||||
"b\tBack (in the page history)\n"
|
"b[N]\tJump back N entries in history, N is optional, default 1\n"
|
||||||
"f\tForward (in the page history)\n"
|
"f[N]\tJump forward N entries in history, N is optional, default 1\n"
|
||||||
"H\tView all page history\n"
|
"H\tView all page history\n"
|
||||||
"m\tSave bookmark\n"
|
"m\tSave bookmark\n"
|
||||||
"M\tBrowse bookmarks\n"
|
"M\tBrowse bookmarks\n"
|
||||||
@ -500,7 +500,9 @@ do_prompts(const char *prompt, struct browser *browser)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
in[n - 1] = 0; // Remove LF
|
in[n - 1] = 0; // Remove LF
|
||||||
|
char *endptr;
|
||||||
|
|
||||||
|
int historyhops = 1;
|
||||||
int r;
|
int r;
|
||||||
switch (in[0]) {
|
switch (in[0]) {
|
||||||
case '\0':
|
case '\0':
|
||||||
@ -511,25 +513,28 @@ do_prompts(const char *prompt, struct browser *browser)
|
|||||||
result = PROMPT_QUIT;
|
result = PROMPT_QUIT;
|
||||||
goto exit;
|
goto exit;
|
||||||
case 'b':
|
case 'b':
|
||||||
if (in[1]) break;
|
if (in[1]) {
|
||||||
if (!browser->history->prev) {
|
historyhops =(int)strtol(in+1, &endptr, 10);
|
||||||
fprintf(stderr, "At beginning of history\n");
|
}
|
||||||
result = PROMPT_AGAIN;
|
while (historyhops > 0) {
|
||||||
goto exit;
|
if (browser->history->prev) {
|
||||||
|
browser->history = browser->history->prev;
|
||||||
|
}
|
||||||
|
historyhops--;
|
||||||
}
|
}
|
||||||
if (in[1]) break;
|
|
||||||
browser->history = browser->history->prev;
|
|
||||||
set_url(browser, browser->history->url, NULL);
|
set_url(browser, browser->history->url, NULL);
|
||||||
result = PROMPT_ANSWERED;
|
result = PROMPT_ANSWERED;
|
||||||
goto exit;
|
goto exit;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (in[1]) break;
|
if (in[1]) {
|
||||||
if (!browser->history->next) {
|
historyhops =(int)strtol(in+1, &endptr, 10);
|
||||||
fprintf(stderr, "At end of history\n");
|
}
|
||||||
result = PROMPT_AGAIN;
|
while (historyhops > 0) {
|
||||||
goto exit;
|
if (browser->history->next) {
|
||||||
|
browser->history = browser->history->next;
|
||||||
|
}
|
||||||
|
historyhops--;
|
||||||
}
|
}
|
||||||
browser->history = browser->history->next;
|
|
||||||
set_url(browser, browser->history->url, NULL);
|
set_url(browser, browser->history->url, NULL);
|
||||||
result = PROMPT_ANSWERED;
|
result = PROMPT_ANSWERED;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -585,7 +590,6 @@ do_prompts(const char *prompt, struct browser *browser)
|
|||||||
case 'p':
|
case 'p':
|
||||||
if (!in[1]) break;
|
if (!in[1]) break;
|
||||||
struct link *link = browser->links;
|
struct link *link = browser->links;
|
||||||
char *endptr;
|
|
||||||
int linksel = (int)strtol(in+1, &endptr, 10);
|
int linksel = (int)strtol(in+1, &endptr, 10);
|
||||||
if (!endptr[0] && linksel >= 0) {
|
if (!endptr[0] && linksel >= 0) {
|
||||||
while (linksel > 0 && link) {
|
while (linksel > 0 && link) {
|
||||||
@ -655,7 +659,6 @@ do_prompts(const char *prompt, struct browser *browser)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct link *link = browser->links;
|
struct link *link = browser->links;
|
||||||
char *endptr;
|
|
||||||
int linksel = (int)strtol(in, &endptr, 10);
|
int linksel = (int)strtol(in, &endptr, 10);
|
||||||
if ((endptr[0] == '\0' || endptr[0] == '|') && linksel >= 0) {
|
if ((endptr[0] == '\0' || endptr[0] == '|') && linksel >= 0) {
|
||||||
while (linksel > 0 && link) {
|
while (linksel > 0 && link) {
|
||||||
|
Loading…
Reference in New Issue
Block a user