From b32537538562df70f5741af7017ca27bd7b04958 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Mon, 20 Jan 2014 13:22:39 +0100 Subject: [PATCH] Implemented goto_tab_nn using Alt+Fn like in Linux console 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 bindings to a simple loop and added more a detailed commit message.] --- tabbedex | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tabbedex b/tabbedex index 3d85e13..9ca58e2 100644 --- a/tabbedex +++ b/tabbedex @@ -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 @@ -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); + } } } @@ -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); } @@ -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) = @_;