From 7d10c9f4f5010c43cad14a123ac609bb76e40f96 Mon Sep 17 00:00:00 2001 From: gryf Date: Tue, 22 Feb 2022 16:50:26 +0100 Subject: [PATCH] Added autohide feature. --- README.rst | 19 ++++++++++++++++--- tabbedalt | 23 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 8468833..22d0da1 100644 --- a/README.rst +++ b/README.rst @@ -29,6 +29,7 @@ Features some text and press ``RETURN`` for accept or ``ESC`` for cancel. * Added ability to configure own shortcuts using standard ``keysym`` urxvt option. See below for examples. +* Autohide tab when there is only one tab at the moment. Installation ------------ @@ -126,6 +127,18 @@ space:: URxvt.tabbedalt.tab-numbers: false +Autohide +~~~~~~~~ + +To hide tab bar, when there is a single tab, the following resource need to be +set to true:: + + URxvt.tabbedalt.autohide: true + +By default tab bar would be visible even with only one tab. Note, that it will +be visible regardless of this option, when ``new-button`` is set. So to make +that option work, you'll need to also disable new-button. + Actions ~~~~~~~ @@ -226,9 +239,9 @@ Resource values are colon separated values, which are in order: Renaming tabs ------------- -On runtime, tabs can be renamed using (by default) ``Shift+Up`` - now you can type name for -the tab. ``Return`` accept change, ``ESC`` cancels it. This feature was taken -from `stepb`_ tabbedx repository. +On runtime, tabs can be renamed using (by default) ``Shift+Up`` - now you can +type name for the tab. ``Return`` accept change, ``ESC`` cancels it. This +feature was taken from `stepb`_ tabbedx repository. .. _urxvt-unicode: http://software.schmorp.de/pkg/rxvt-unicode.html .. _activity indicator: http://mina86.com/2009/05/16/tabbed-urxvt-extension/ diff --git a/tabbedalt b/tabbedalt index 863f5b3..8413be9 100644 --- a/tabbedalt +++ b/tabbedalt @@ -139,6 +139,9 @@ # # 2022-02-20 18:31:19 # - Fixed nasty bug in renaming tab. +# +# 2022-02-22 16:49:18 +# - Added feature with autohide tabbar, if there is only single tab use Scalar::Util; @@ -240,6 +243,19 @@ sub tab_term_init { sub refresh { my ($self) = @_; + my $tabs_no = (@{$self->{tabs}}); + + if (! $self->{new_button} && $self->{autohide} && $tabs_no == 1 && + ! $self->{cur}->{is_being_renamed}) { + $self->{tabheight} = 0; + $self->configure; + $self->copy_properties; + return; + } else { + $self->{tabheight} = $self->{_tab_height_if_visible}; + $self->configure; + $self->copy_properties; + } my $ncol = $self->ncol; @@ -519,6 +535,7 @@ sub init { $self->{rs_tab_acs} = urxvt::SET_COLOR(urxvt::DEFAULT_RSTYLE, $actives + 2, $bg + 2); $self->{rs_tab_acd} = urxvt::SET_COLOR(urxvt::DEFAULT_RSTYLE, $actived + 2, $bg + 2); $self->{set_default_keys} = (! $self->x_resource_boolean('disable-default-keys')); + $self->{autohide} = $self->x_resource_boolean('autohide'); my $timeouts = $self->x_resource ("tabbar-timeouts"); $timeouts = '16:.:8:::4:+' unless defined $timeouts; @@ -544,10 +561,12 @@ sub init { } -_on start => sub { +_on start => sub { my ($self) = @_; - $self->{tabheight} = $self->int_bwidth + $self->fheight + $self->lineSpace; + $self->{_tab_height_if_visible} = $self->int_bwidth + $self->fheight + + $self->lineSpace; + $self->{tabheight} = $self->{autohide}? 0 : $self->{_tab_height_if_visible}; $self->cmd_parse ("\033[?25l");