Allow hiding the tab bar completely, by setting :opt:tab_bar_style to `hidden`.

Fixes #1014
This commit is contained in:
Kovid Goyal
2018-10-25 10:05:43 +05:30
parent 407d19c2dc
commit e113e0cba7
5 changed files with 23 additions and 10 deletions

View File

@@ -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`)

View File

@@ -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.
'''))

View File

@@ -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++) {

View File

@@ -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;

View File

@@ -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()