From 213768b6e0bc91c3f263837c5b05755be44ee077 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Jan 2018 17:04:58 +0530 Subject: [PATCH] Option to place tab bar at the top edge Fixes #288 --- kitty/config.py | 5 +++++ kitty/kitty.conf | 9 +++++++-- kitty/state.c | 19 +++++++++++++++---- kitty/state.h | 3 +++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/kitty/config.py b/kitty/config.py index 01d68ae93..ce7aab3c6 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -234,6 +234,10 @@ def tab_font_style(x): return {'bold-italic': (True, True), 'bold': (True, False), 'italic': (False, True)}.get(x.lower().replace('_', '-'), (False, False)) +def tab_bar_edge(x): + return {'top': 1, 'bottom': 3}.get(x.lower(), 3) + + def url_style(x): return url_style.map.get(x, url_style.map['curly']) @@ -282,6 +286,7 @@ type_map = { 'url_style': url_style, 'prefer_color_emoji': to_bool, 'copy_on_select': to_bool, + 'tab_bar_edge': tab_bar_edge, } for name in ( diff --git a/kitty/kitty.conf b/kitty/kitty.conf index a0546f999..c2e9efd33 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -196,14 +196,19 @@ inactive_border_color #cccccc # zero and one, with 0 being fully faded). inactive_text_alpha 1.0 -# Tab-bar customization +# Which edge to show the tab bar on, top or bottom +tab_bar_edge bottom + +# The separator between tabs in the tab bar +tab_separator " ┇" + +# Tab bar colors and styles active_tab_foreground #000 active_tab_background #eee active_tab_font_style bold-italic inactive_tab_foreground #444 inactive_tab_background #999 inactive_tab_font_style normal -tab_separator " ┇" # The 16 terminal colors. There are 8 basic colors, each color has a dull and diff --git a/kitty/state.c b/kitty/state.c index 8451c57b7..410272e01 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -245,10 +245,20 @@ add_borders_rect(id_type os_window_id, id_type tab_id, uint32_t left, uint32_t t void os_window_regions(OSWindow *os_window, Region *central, Region *tab_bar) { if (os_window->num_tabs > 1) { - central->left = 0; central->top = 0; central->right = os_window->viewport_width - 1; - central->bottom = os_window->viewport_height - global_state.cell_height - 1; - tab_bar->left = central->left; tab_bar->right = central->right; tab_bar->top = central->bottom + 1; - tab_bar->bottom = os_window->viewport_height - 1; + switch(OPT(tab_bar_edge)) { + case TOP_EDGE: + central->left = 0; central->top = global_state.cell_height; central->right = os_window->viewport_width - 1; + central->bottom = os_window->viewport_height - 1; + tab_bar->left = central->left; tab_bar->right = central->right; tab_bar->top = 0; + tab_bar->bottom = central->top - 1; + break; + default: + central->left = 0; central->top = 0; central->right = os_window->viewport_width - 1; + central->bottom = os_window->viewport_height - global_state.cell_height - 1; + tab_bar->left = central->left; tab_bar->right = central->right; tab_bar->top = central->bottom + 1; + tab_bar->bottom = os_window->viewport_height - 1; + break; + } } else { memset(tab_bar, 0, sizeof(Region)); central->left = 0; central->top = 0; central->right = os_window->viewport_width - 1; @@ -330,6 +340,7 @@ PYWRAP1(set_options) { S(cursor_shape, PyLong_AsLong); S(url_style, PyLong_AsUnsignedLong); S(x11_bell_volume, PyLong_AsLong); + S(tab_bar_edge, PyLong_AsLong); S(mouse_hide_wait, PyFloat_AsDouble); S(wheel_scroll_multiplier, PyFloat_AsDouble); S(open_url_modifiers, PyLong_AsUnsignedLong); diff --git a/kitty/state.h b/kitty/state.h index 8e196c899..119b48602 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -10,6 +10,8 @@ #define OPT(name) global_state.opts.name +typedef enum { LEFT_EDGE, TOP_EDGE, RIGHT_EDGE, BOTTOM_EDGE } Edge; + typedef struct { double visual_bell_duration, cursor_blink_interval, cursor_stop_blinking_after, mouse_hide_wait, click_interval, wheel_scroll_multiplier; bool enable_audio_bell; @@ -28,6 +30,7 @@ typedef struct { float adjust_line_height_frac; float background_opacity; float inactive_text_alpha; + Edge tab_bar_edge; } Options; typedef struct {