mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Display optionally tabs bar at top like other browser do.
TODO: input_line_layouter, ACT_MAIN_TAB_MENU
This commit is contained in:
parent
a802f0fb3e
commit
3f01c3d2fe
@ -1161,6 +1161,10 @@ static struct option_info config_options_info[] = {
|
||||
"1 means only if two or more tabs are open\n"
|
||||
"2 means always")),
|
||||
|
||||
INIT_OPT_BOOL("ui.tabs", N_("Tab bar at top"),
|
||||
"top", 0, 0,
|
||||
N_("Whether display tab bar at top like other browsers do.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.tabs", N_("Wrap-around tabs cycling"),
|
||||
"wraparound", 0, 1,
|
||||
N_("When moving right from the last tab, jump at the first one, and\n"
|
||||
|
@ -67,6 +67,7 @@ update_status(void)
|
||||
int show_title_bar = get_opt_bool("ui.show_title_bar");
|
||||
int show_status_bar = get_opt_bool("ui.show_status_bar");
|
||||
int show_tabs_bar = get_opt_int("ui.tabs.show_bar");
|
||||
int show_tabs_bar_at_top = get_opt_bool("ui.tabs.top");
|
||||
#ifdef CONFIG_LEDS
|
||||
int show_leds = get_opt_bool("ui.leds.enable");
|
||||
#endif
|
||||
@ -105,6 +106,13 @@ update_status(void)
|
||||
status->show_tabs_bar = show_tabs(show_tabs_bar, tabs);
|
||||
dirty = 1;
|
||||
}
|
||||
|
||||
if (status->show_tabs_bar) {
|
||||
if (status->show_tabs_bar_at_top != show_tabs_bar_at_top) {
|
||||
status->show_tabs_bar_at_top = show_tabs_bar_at_top;
|
||||
dirty = 1;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_LEDS
|
||||
if (status->show_leds != show_leds) {
|
||||
status->show_leds = show_leds;
|
||||
@ -290,7 +298,8 @@ display_tab_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
int tab_num;
|
||||
struct box box;
|
||||
|
||||
set_box(&box, 0, term->height - (status->show_status_bar ? 2 : 1), 0, 1);
|
||||
if (status->show_tabs_bar_at_top) set_box(&box, 0, status->show_title_bar, term->width, 1);
|
||||
else set_box(&box, 0, term->height - (status->show_status_bar ? 2 : 1), 0, 1);
|
||||
|
||||
for (tab_num = 0; tab_num < tabs_count; tab_num++) {
|
||||
struct download *download = NULL;
|
||||
|
@ -430,7 +430,10 @@ render_document_frames(struct session *ses, int no_cache)
|
||||
doc_opts.box.height--;
|
||||
}
|
||||
if (ses->status.show_status_bar) doc_opts.box.height--;
|
||||
if (ses->status.show_tabs_bar) doc_opts.box.height--;
|
||||
if (ses->status.show_tabs_bar) {
|
||||
doc_opts.box.height--;
|
||||
if (ses->status.show_tabs_bar_at_top) doc_opts.box.y++;
|
||||
}
|
||||
|
||||
doc_opts.color_mode = get_opt_int_tree(ses->tab->term->spec, "colors");
|
||||
if (!get_opt_bool_tree(ses->tab->term->spec, "underline"))
|
||||
|
@ -106,6 +106,7 @@ struct session_status {
|
||||
|
||||
/* Is processing file requests. */
|
||||
unsigned int processing_file_requests:1;
|
||||
unsigned int show_tabs_bar_at_top:1;
|
||||
};
|
||||
|
||||
enum insert_mode {
|
||||
|
@ -1007,6 +1007,17 @@ do_mouse_event(struct session *ses, struct term_event *ev,
|
||||
return send_to_frame(ses, doc_view, &evv);
|
||||
}
|
||||
|
||||
static int
|
||||
is_mouse_on_tab_bar(struct session *ses, struct term_event_mouse *mouse)
|
||||
{
|
||||
struct terminal *term = ses->tab->term;
|
||||
int y;
|
||||
|
||||
if (ses->status.show_tabs_bar_at_top) y = ses->status.show_title_bar;
|
||||
else y = term->height - 1 - !!ses->status.show_status_bar;
|
||||
|
||||
return mouse->y == y;
|
||||
}
|
||||
/* Returns the session if event cleanup should be done or NULL if no cleanup is
|
||||
* needed. */
|
||||
static struct session *
|
||||
@ -1029,8 +1040,7 @@ send_mouse_event(struct session *ses, struct document_view *doc_view,
|
||||
}
|
||||
|
||||
/* Handle tabs navigation if tabs bar is displayed. */
|
||||
if (ses->status.show_tabs_bar
|
||||
&& mouse->y == term->height - 1 - !!ses->status.show_status_bar) {
|
||||
if (ses->status.show_tabs_bar && is_mouse_on_tab_bar(ses, mouse)) {
|
||||
int tab_num = get_tab_number_by_xpos(term, mouse->x);
|
||||
struct window *tab = get_current_tab(term);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user