mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[action] Added reopen-last-closed-tab action. Refs #309
The uri of the latest closed tab uri is remembered in struct terminal. And when the reopen-last-closed-tab action is executed, then uri is open in new tab in foreground. Only one is in memory. If you close two tabs, only on one of them can be reopened. No key is assigned to this action by default.
This commit is contained in:
parent
7025f8da92
commit
24b3adfc9d
@ -100,6 +100,7 @@ ACTION_(MAIN, "quit", QUIT, N__("Open a quit confirmation dialog box"), 0),
|
||||
ACTION_(MAIN, "really-quit", REALLY_QUIT, N__("Quit without confirmation"), 0),
|
||||
ACTION_(MAIN, "redraw", REDRAW, N__("Redraw the terminal"), 0),
|
||||
ACTION_(MAIN, "reload", RELOAD, N__("Reload the current page"), 0),
|
||||
ACTION_(MAIN, "reopen-last-closed-tab", REOPEN_LAST_CLOSED_TAB, N__("Reopen last closed tab"), 0),
|
||||
ACTION_(MAIN, "rerender", RERENDER, N__("Re-render the current page"), 0),
|
||||
ACTION_(MAIN, "reset-form", RESET_FORM, N__("Reset form items to their initial values"), ACTION_REQUIRE_VIEW_STATE | ACTION_REQUIRE_LOCATION),
|
||||
ACTION_(MAIN, "resource-info", RESOURCE_INFO, N__("Show information about the currently used resources"), 0),
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "intl/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "terminal/screen.h"
|
||||
#include "terminal/tab.h"
|
||||
@ -186,6 +187,14 @@ really_close_tab(void *ses_)
|
||||
struct session *ses = (struct session *)ses_;
|
||||
struct terminal *term = ses->tab->term;
|
||||
struct window *current_tab = get_current_tab(term);
|
||||
struct uri *uri = have_location(ses) ? cur_loc(ses)->vs.uri : ses->loading_uri;
|
||||
|
||||
if (uri) {
|
||||
if (term->closed_tab_uri) {
|
||||
done_uri(term->closed_tab_uri);
|
||||
}
|
||||
term->closed_tab_uri = get_uri_reference(uri);
|
||||
}
|
||||
|
||||
if (ses->tab == current_tab) {
|
||||
int tabs_count = number_of_tabs(term);
|
||||
|
@ -286,6 +286,11 @@ destroy_terminal(struct terminal *term)
|
||||
}
|
||||
|
||||
object_unlock(term->spec);
|
||||
|
||||
if (term->closed_tab_uri) {
|
||||
done_uri(term->closed_tab_uri);
|
||||
}
|
||||
|
||||
mem_free(term);
|
||||
check_if_no_terminal();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define EL__TERMINAL_TERMINAL_H
|
||||
|
||||
#include "config/options.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "terminal/event.h"
|
||||
#include "util/lists.h"
|
||||
|
||||
@ -182,6 +183,8 @@ struct terminal {
|
||||
#endif
|
||||
int cell_width;
|
||||
int cell_height;
|
||||
|
||||
struct uri *closed_tab_uri;
|
||||
};
|
||||
|
||||
#define do_not_ignore_next_mouse_event(term) \
|
||||
|
@ -675,6 +675,14 @@ do_action(struct session *ses, main_action_T action_id, int verbose)
|
||||
close_all_tabs_but_current(ses);
|
||||
break;
|
||||
|
||||
case ACT_MAIN_REOPEN_LAST_CLOSED_TAB:
|
||||
if (term->closed_tab_uri) {
|
||||
open_uri_in_new_tab(ses, term->closed_tab_uri, 0, 1);
|
||||
done_uri(term->closed_tab_uri);
|
||||
term->closed_tab_uri = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case ACT_MAIN_TAB_EXTERNAL_COMMAND:
|
||||
status = pass_uri_to_command(ses, doc_view,
|
||||
PASS_URI_TAB);
|
||||
|
Loading…
Reference in New Issue
Block a user