hello,

I discoverer tabbed few days ago but I have some trouble with its shortcuts
(habits, own shortcuts, fingers on more than one key, etc.). So, here is a
litle patch that enables:
 - the definition of key modifiers for tabs management and moving. It supports
   shift, control, meta, or any combinaison of them.
 - the deactivation of the tabs moving (using no value)

In the hope that it could be useful.


best regards,

Rémi Hérilier
--- tabbed.orig	2010-12-08 18:52:36.000000000 +0100
+++ tabbed	2010-12-09 22:23:17.000000000 +0100
@@ -154,6 +154,30 @@
    ()
 }
 
+sub parse_key_modifiers {
+   my ($self, $mode, $default, $nullable) = @_;
+   my $mask = 0;
+   my $param = $self->x_resource ($mode);
+
+   defined $param or $param = $default;
+   ($nullable || $param ne "") or $param = $default;
+
+   my @mods = split('', $param);
+   for my $mod (@mods) {
+       if ($mod eq "C") {
+           $mask |= urxvt::ControlMask;
+       } elsif ($mod eq "S") {
+           $mask |= urxvt::ShiftMask;
+       } elsif ($mod eq "M") {
+           $mask |= $self->ModMetaMask;
+       } else {
+           warn("modifier '$mod' in URxvt.tabbed.$mode is ignored\n");
+       }
+   }
+
+   $mask
+}
+
 sub on_focus_in {
    my ($self, $event) = @_;
 
@@ -242,6 +266,9 @@
 
    $self->cmd_parse ("\033[?25l");
 
+   $self->{mngt_keymod} = $self->parse_key_modifiers ("mngt-keymod", "S", 0);
+   $self->{move_keymod} = $self->parse_key_modifiers ("move-keymod", "C", 1);
+
    my @argv = $self->argv;
 
    do {
@@ -306,7 +333,7 @@
 sub tab_key_press {
    my ($self, $tab, $event, $keysym, $str) = @_;
 
-   if ($event->{state} & urxvt::ShiftMask) {
+   if ($self->{mngt_keymod} && $event->{state} == $self->{mngt_keymod}) {
       if ($keysym == 0xff51 || $keysym == 0xff53) {
          my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
 
@@ -322,7 +349,7 @@
          return 1;
       }
    }
-   elsif ($event->{state} & urxvt::ControlMask) {
+   elsif ($self->{move_keymod} && $event->{state} == $self->{move_keymod}) {
       if ($keysym == 0xff51 || $keysym == 0xff53) {
          my ($idx1) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
          my  $idx2  = ($idx1 + ($keysym == 0xff51 ? -1 : +1)) % @{ $self->{tabs} };
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to