diff options
| -rw-r--r-- | urxvt/ext/tabbed | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/urxvt/ext/tabbed b/urxvt/ext/tabbed index e8036ca..f46059c 100644 --- a/urxvt/ext/tabbed +++ b/urxvt/ext/tabbed @@ -237,19 +237,32 @@ sub on_tt_write { sub on_key_press { my ($self, $event) = @_; - $self->{cur}->key_press ($event->{state}, $event->{keycode}, $event->{time}); - $self->{cur}->refresh_check; + my $is_alt = ($event->{state} & urxvt::Mod1Mask) != 0; + my $keysym = 0; + eval { $keysym = $self->XKeycodeToKeysym ($event->{keycode}, 0); }; + $keysym = 0 unless defined $keysym; - 1 + if ($is_alt && $keysym == 0x0074) { # Alt+T -> new tab + $self->new_tab; + return 1; + } + + if ($is_alt && ($keysym == 0xff51 || $keysym == 0xff53)) { # Alt+Left/Right + my $tabs = $self->{tabs} || []; + if (@$tabs) { + my ($idx) = grep $tabs->[$_] == $self->{cur}, 0 .. $#$tabs; + $idx = 0 if !defined $idx; + $idx += ($keysym == 0xff51) ? -1 : +1; + $self->make_current ($tabs->[$idx % @$tabs]); + } + return 1; + } + () } sub on_key_release { my ($self, $event) = @_; - - $self->{cur}->key_release ($event->{state}, $event->{keycode}, $event->{time}); - $self->{cur}->refresh_check; - - 1 + () } sub on_button_press { @@ -430,7 +443,7 @@ package urxvt::ext::tabbed::tab; # simply proxies all interesting calls back to the tabbed class. { - for my $hook (qw(start destroy key_press property_notify)) { + for my $hook (qw(start destroy property_notify)) { eval qq{ sub on_$hook { my \$parent = \$_[0]{term}{parent} @@ -442,6 +455,18 @@ package urxvt::ext::tabbed::tab; } } +sub on_key_press { + my ($self, $event) = @_; + my $parent = $self->{term}{parent} + or return; + + my $keysym = 0; + eval { $keysym = $self->XKeycodeToKeysym ($event->{keycode}, 0); }; + $keysym = 0 unless defined $keysym; + + return $parent->tab_key_press ($self, $event, $keysym, ""); +} + sub on_add_lines { $_[0]->{activity}++ or $_[0]{term}{parent}->tab_activity ($_[0]); |
