1
0
mirror of https://github.com/gryf/tabbedalt.git synced 2025-12-17 19:40:31 +01:00

Added default shortcut for the new tab creation.

In my derivation I arbitrary choose ctrl+shift+n as a shortcut for
creating new shell tab. There was a bug, when user created some other
class (for example for midnight commander and root) and with such
configuration it will unable to create default shell tabs.

This change introduces standard shortcut from original tabbed extension
(shift+down) as a default one for creating shell tabs. All the shell
classes can be configured and used as before.

Shift+down shortcut can be disabled, and now, "new style" - ctrl+shift+n
shortcut would be used for that purpose, unless user provide its own
class definition for that shortcut, than user responsibility is to make
appropriate shortcut for default shell.
This commit is contained in:
2019-09-13 19:14:49 +02:00
parent 5588a30dd4
commit 317f614e8f
2 changed files with 47 additions and 17 deletions

View File

@@ -9,16 +9,16 @@ Features
--------
* Possibility to add named tabs, through the X resources, which represents its
*class*. Without any configuration only simple shell *class* is available
under CTRL+SHIFT+N shortcut. After creating first custom shell this default
will be discarded.
*class*. Without any configuration only default shell *class* is available
under default (``Shift+Down``) shortcut. It might be disabled, and it will
become "new style" shortcut - ``Ctrl+Shift+N``. See configuration section
below.
.. image:: /screens/tabbed.png
:alt: Named tabs
* Shortcuts can be attached to Super_L and Super_R keys together with others
* Fast navigation to first ten tabs (if available) with shortcut CTRL+[num],
where *num* can be 0 to 9. CTRL+0 will switch to tenth tab.
* Fast navigation to first ten tabs (if available) with shortcut ``Ctrl+[num]``,
where *num* can be 0 to 9. ``CTRL+0`` will switch to tenth tab.
* Numbers in tabs can be switched off in by setting
resource:``URxvt.tabbed.tab-numbers: false``
* Integrated `activity indicator`_ with additional features like colors and
@@ -27,8 +27,8 @@ Features
.. image:: /screens/tabbed.gif
:alt: Indicator activity
* Integrated tab renaming from `stepb`_. Default under SHIFT+UP, then type some
text and RETURN for accept, ESC for cancel.
* Integrated tab renaming from `stepb`_. Default under ``Shift+UP``, then type
some text and press ``RETURN`` for accept or ``ESC`` for cancel.
Installation
------------
@@ -140,7 +140,29 @@ and also other characters (digits, some special characters etc.). Letters are
case insensitive.
* **name of the tab**, it could be anything but the pipe.
* **optional command**. If omitted, simple shell will be launched.
* **optional command**. If omitted, default shell will be launched.
By default, there is default shortcut available for creating standard shell
(like the *shell* class from example above) under ``Shift+Down``. It might be
however disabled by setting::
URxvt.tabbed.disable-shift-down: false
and from now on, default ``Ctrl+Shift+N`` shortcut will be available for
creating new shell, if there is no existing mapping for this shortcut. You can
override the mapping for something different, getting above example, we will
override first class, which reside under shortcut ``Ctrl+Shift+N``::
URxvt.tabbed.tabcmds.1: N|rss|newsboat
But beware, from now on, you'll be unable to create simple shell tabs, unless
you explicitly create class for a shell, so the full changed example will looks
like::
URxvt.tabbed.tabcmds.1: N|rss|newsboat
URxvt.tabbed.tabcmds.2: R|root|su -
URxvt.tabbed.tabcmds.3: M|mc|mc
URxvt.tabbed.tabcmds.4: S|shell
Startup tabs
------------
@@ -151,7 +173,7 @@ Let's assume, that there are already defined three custom shells, like in
section above. If one wanted to start shell, mc and root session, following
line should be placed in ``~/.Xdefaults``::
URxvt.tabbed.session: N|M|R
URxvt.tabbed.session: S|M|R
Renaming tabs
-------------

22
tabbed
View File

@@ -107,7 +107,10 @@
# 2019-06-05 10:55:37
# - fixed couple of bugs regarding session
# - changed default colors to more sane values
#
# 2019-09-13 15:15:18
# - Added shortcut for creating new shell like in original tabbed
# (SHIFT+Down). It can be disabled by an option "disable-shift-down".
sub tab_activity_mark ($$) {
my ($self, $tab) = @_;
@@ -417,6 +420,10 @@ sub on_init {
$self->{tab_numbers} =
($self->x_resource ('tab-numbers') or 'true') !~ /^(?:false|0|no)/i;
$self->{disable_shift_down} =
($self->x_resource ('disable-shift-down')
or 'false') =~ /^(?:true|1|yes)/i;
%{$self->{tabcmds}} = ();
for (my $idx = 1; defined (my $res = $self->x_resource("tabcmds.$idx")); $idx++){
chomp($res);
@@ -557,14 +564,12 @@ sub tab_key_press {
if ($event->{state} & urxvt::ShiftMask) {
if ($event->{state} & urxvt::ControlMask) {
if(not %{$self->{tabcmds}}){
if ($keysym == 0x4e){
$self->new_tab("shell");
return 1;
}
}elsif(exists($self->{tabcmds}{chr($keysym)})){
if (exists($self->{tabcmds}{chr($keysym)})) {
$self->new_tab(@{$self->{tabcmds}{chr($keysym)}});
return 1;
} elsif ($self->{disable_shift_down} and $keysym == 0x4e) {
$self->new_tab("shell");
return 1;
}
}elsif ($keysym == 0xff51 || $keysym == 0xff53) {
my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
@@ -582,6 +587,9 @@ sub tab_key_press {
$tab->{name} = "█";
$self->refresh;
return 1;
} elsif (not $self->{disable_shift_down} and $keysym == 0xff54) {
$self->new_tab("shell");
return 1;
}
}
elsif ($event->{state} & urxvt::ControlMask) {