1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00:00

optionally, going back from initial page closes tab or elinks

This commit is contained in:
sgerwk 2021-03-13 09:58:09 +01:00
parent 90cbad07d3
commit d894f563d0
4 changed files with 14 additions and 4 deletions

View File

@ -1488,6 +1488,10 @@ static union option_info config_options_info[] = {
"Changes take effect at the next elinks restart.")),
#endif
INIT_OPT_BOOL("ui", N_("Back to exit"),
"back_to_exit", 0, 0,
N_("Going back from initial page exits tab or elinks.")),
INIT_OPT_BOOL("ui", N_("Set window title"),
"window_title", 0, 1,
N_("Set the window title when running in a windowing "

View File

@ -165,12 +165,13 @@ go_history(struct session *ses, struct location *loc)
CACHE_MODE_ALWAYS, TASK_HISTORY, 0);
}
void
int
go_history_by_n(struct session *ses, int n)
{
struct location *loc = cur_loc(ses);
if (!loc) return;
if (!loc)
return -1;
if (n > 0) {
while (n-- && list_has_next(ses->history.history, loc))
@ -178,9 +179,12 @@ go_history_by_n(struct session *ses, int n)
} else {
while (n++ && list_has_prev(ses->history.history, loc))
loc = loc->prev;
if (n == 0 && ! list_has_prev(ses->history.history, loc))
return -1;
}
go_history(ses, loc);
return 0;
}
/** Go backward in the history. See go_history() description regarding

View File

@ -40,7 +40,7 @@ void go_history(struct session *ses, struct location *loc);
/** Move back -@a n times if @a n is negative, forward @a n times if
* positive. */
void go_history_by_n(struct session *ses, int n);
int go_history_by_n(struct session *ses, int n);
void go_back(struct session *ses);
void go_unback(struct session *ses);

View File

@ -255,7 +255,9 @@ do_action(struct session *ses, enum main_action action_id, int verbose)
{
int count = int_max(1, eat_kbd_repeat_count(ses));
go_history_by_n(ses, -count);
if (go_history_by_n(ses, -count) &&
get_opt_bool("ui.back_to_exit", NULL))
close_tab(term, ses);
break;
}
case ACT_MAIN_HISTORY_MOVE_FORWARD: