Skip to content

Commit

Permalink
Implemented goto_tab_nn using Alt+Fn like in Linux console
Browse files Browse the repository at this point in the history
This may potentially break existing console applications which use Alt-Fn
for something.  In that case, the fix is to add the following to one's
.Xresources:

urxvt.tabbed.no-tabbedex-keys: yes
urxvt.keysym.Shift-Left: perl:tabbedex:prev_tab
urxvt.keysym.Shift-Right: perl:tabbedex:next_tab
urxvt.keysym.Shift-Down: perl:tabbedex:new_tab
urxvt.keysym.Shift-Up: perl:tabbedex:rename_tab
urxvt.keysym.Control-Left: perl:tabbedex:move_tab_left
urxvt.keysym.Control-Right: perl:tabbedex:move_tab_right

In case no-tabbedex-keys is already used, to enable goto_tab_nn bindings
the following needs to be added instead:

urxvt.keysym.Meta-F1: perl:tabbedex:goto_tab_1
urxvt.keysym.Meta-F2: perl:tabbedex:goto_tab_2
urxvt.keysym.Meta-F3: perl:tabbedex:goto_tab_3
urxvt.keysym.Meta-F4: perl:tabbedex:goto_tab_4
urxvt.keysym.Meta-F5: perl:tabbedex:goto_tab_5
urxvt.keysym.Meta-F6: perl:tabbedex:goto_tab_6
urxvt.keysym.Meta-F7: perl:tabbedex:goto_tab_7
urxvt.keysym.Meta-F8: perl:tabbedex:goto_tab_8
urxvt.keysym.Meta-F9: perl:tabbedex:goto_tab_9
urxvt.keysym.Meta-F10: perl:tabbedex:goto_tab_10
urxvt.keysym.Meta-F11: perl:tabbedex:goto_tab_11
urxvt.keysym.Meta-F12: perl:tabbedex:goto_tab_12

[mina86@mina86.com: Changed Meta-F<n> bindings to a simple loop
 and added more a detailed commit message.]
  • Loading branch information
mina86 committed Jan 20, 2014
1 parent e9cff63 commit b325375
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tabbedex
Expand Up @@ -3,7 +3,7 @@
## TabbedEx plugin for rxvt-unicode
## Based on original tabbed plugin.
## Copyright (c) 2006-2012 tabbed authors
## Copyright (c) 2009-2013 tabbedex authors
## Copyright (c) 2009-2014 tabbedex authors
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -514,6 +514,10 @@ sub register_keysyms {
$tab->parse_keysym('Shift-Up', 'perl:tabbedex:rename_tab');
$tab->parse_keysym('Control-Left', 'perl:tabbedex:move_tab_left');
$tab->parse_keysym('Control-Right', 'perl:tabbedex:move_tab_right');
for my $num (1..12) {
$tab->parse_keysym('Meta-F' . $num,
'perl:tabbedex:goto_tab_' . $num);
}
}
}

Expand Down Expand Up @@ -726,6 +730,9 @@ sub tab_user_command {
elsif ($cmd eq 'tabbedex:move_tab_right') {
$self->move_tab($tab, 1);
}
elsif ($cmd =~ /^tabbedex:goto_tab_(\d+)$/) {
$self->change_to_tab($tab, $1 - 1);
}
elsif ($cmd eq 'tabbedex:rename_tab') {
$self->rename_tab($tab);
}
Expand Down Expand Up @@ -755,6 +762,16 @@ sub change_tab {
();
}

sub change_to_tab {
my ($self, $tab, $idx) = @_;

if (!$self->{is_inputting_name} && @{ $self->{tabs} } > 1 && $idx >= 0 && $idx < @{ $self->{tabs} }) {
$self->make_current ($self->{tabs}[$idx]);
}

();
}

sub move_tab {
my ($self, $tab, $direction) = @_;

Expand Down

0 comments on commit b325375

Please sign in to comment.