From e113e0cba70d1e86644053f9ab5f9f9cc82c4282 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 Oct 2018 10:05:43 +0530 Subject: [PATCH] Allow hiding the tab bar completely, by setting :opt:`tab_bar_style` to ``hidden``. Fixes #1014 --- docs/changelog.rst | 3 +++ kitty/config_data.py | 4 ++-- kitty/state.c | 7 ++++++- kitty/state.h | 1 + kitty/tabs.py | 18 +++++++++++------- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 2bcb44b30..5e5663ae7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -20,6 +20,9 @@ Changelog ``goto_tab`` now accepts negative numbers to go to previously active tabs (:iss:`1040`) +- Allow hiding the tab bar completely, by setting :opt:`tab_bar_style` to + ``hidden``. (:iss:`1014`) + - Fix the ``*_with_cwd`` actions using the cwd of the overlay window rather than the underlying window's cwd (:iss:`1045`) diff --git a/kitty/config_data.py b/kitty/config_data.py index 882e32fb4..169776f64 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -572,8 +572,8 @@ Which edge to show the tab bar on, top or bottom''')) o('tab_bar_margin_width', 0.0, option_type=positive_float, long_text=_(''' The margin to the left and right of the tab bar (in pts)''')) -o('tab_bar_style', 'fade', option_type=choices('fade', 'separator'), long_text=_(''' -The tab bar style, can be one of: :code:`fade` or :code:`separator`. In the fade style, +o('tab_bar_style', 'fade', option_type=choices('fade', 'separator', 'hidden'), long_text=_(''' +The tab bar style, can be one of: :code:`fade`, :code:`separator` or :code:`hidden`. In the fade style, each tab's edges fade into the background color, in the separator style, tabs are separated by a configurable separator. ''')) diff --git a/kitty/state.c b/kitty/state.c index 2c85d56f2..91970d1a4 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -249,7 +249,7 @@ 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) { + if (!global_state.tab_bar_hidden && os_window->num_tabs > 1) { switch(OPT(tab_bar_edge)) { case TOP_EDGE: central->left = 0; central->top = os_window->fonts_data->cell_height; central->right = os_window->viewport_width - 1; @@ -395,6 +395,11 @@ PYWRAP1(set_options) { S(macos_hide_from_tasks, PyObject_IsTrue); S(macos_thicken_font, PyFloat_AsDouble); + GA(tab_bar_style); if (!ret) return NULL; + global_state.tab_bar_hidden = PyUnicode_CompareWithASCIIString(ret, "hidden") == 0 ? true: false; + Py_CLEAR(ret); + if (PyErr_Occurred()) return NULL; + PyObject *chars = PyObject_GetAttrString(opts, "select_by_word_characters"); if (chars == NULL) return NULL; for (size_t i = 0; i < MIN((size_t)PyUnicode_GET_LENGTH(chars), sizeof(OPT(select_by_word_characters))/sizeof(OPT(select_by_word_characters[0]))); i++) { diff --git a/kitty/state.h b/kitty/state.h index d7bf4e5e4..ccb0bc2e6 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -143,6 +143,7 @@ typedef struct { bool debug_gl, debug_font_fallback; bool has_pending_resizes; bool in_sequence_mode; + bool tab_bar_hidden; double font_sz_in_pts; struct { double x, y; } default_dpi; id_type active_drag_in_window; diff --git a/kitty/tabs.py b/kitty/tabs.py index 927e8f0d9..47910dc94 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -358,6 +358,7 @@ class TabManager: # {{{ self.os_window_id = os_window_id self.last_active_tab_id = None self.opts, self.args = opts, args + self.tab_bar_hidden = self.opts.tab_bar_style == 'hidden' self.tabs = [] self.active_tab_history = deque() self.tab_bar = TabBar(self.os_window_id, opts) @@ -395,7 +396,8 @@ class TabManager: # {{{ w.focus_changed(True) def refresh_sprite_positions(self): - self.tab_bar.screen.refresh_sprite_positions() + if not self.tab_bar_hidden: + self.tab_bar.screen.refresh_sprite_positions() def _add_tab(self, tab): before = len(self.tabs) @@ -415,12 +417,13 @@ class TabManager: # {{{ set_active_tab(self.os_window_id, idx) def tabbar_visibility_changed(self): - self.tab_bar.layout() - self.resize(only_tabs=True) - glfw_post_empty_event() + if not self.tab_bar_hidden: + self.tab_bar.layout() + self.resize(only_tabs=True) + glfw_post_empty_event() def mark_tab_bar_dirty(self): - if len(self.tabs) > 1: + if len(self.tabs) > 1 and not self.tab_bar_hidden: mark_tab_bar_dirty(self.os_window_id) def update_tab_bar_data(self): @@ -428,8 +431,9 @@ class TabManager: # {{{ def resize(self, only_tabs=False): if not only_tabs: - self.tab_bar.layout() - self.mark_tab_bar_dirty() + if not self.tab_bar_hidden: + self.tab_bar.layout() + self.mark_tab_bar_dirty() for tab in self.tabs: tab.relayout()