Home > Uncategorized > 增强rxvt-unicode的tab功能

增强rxvt-unicode的tab功能

这个补丁的功能是

  1. 可以通过ctrl + n切换tab
  2. 一个看着更舒服的tab样式
diff -rupN orig/tabbed new/tabbed
--- orig/tabbed 2009-04-20 10:23:35.000000000 +0800
+++ new/tabbed  2009-04-20 10:29:38.000000000 +0800
@@ -10,8 +10,8 @@ sub refresh {

    my @ofs;

-   substr $text, 0, 7, "[NEW] |";
-   @$rend[0 .. 5] = ($self->{rs_tab}) x 6;
+   substr $text, 0, 7, "  NEW  ";
+   @$rend[0 .. 5] = ($self->{rs_tabbar}) x 6;
    push @ofs, [0, 6, sub { $_[0]->new_tab }];

    my $ofs = 7;
@@ -26,7 +26,7 @@ sub refresh {
       my $txt = "$act$idx$act";
       my $len = length $txt;

-      substr $text, $ofs, $len + 1, "$txt|";
+      substr $text, $ofs, $len + 1, "$txt ";
       @$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab}) x $len
          if $tab == $self->{cur};

@@ -224,10 +224,10 @@ sub on_init {
    my $tabfg = $self->x_resource ("tab-fg");
    my $tabbg = $self->x_resource ("tab-bg");

-   defined $fg    or $fg    = 3;
-   defined $bg    or $bg    = 0;
-   defined $tabfg or $tabfg = 0;
-   defined $tabbg or $tabbg = 1;
+   defined $fg    or $fg    = 0;
+   defined $bg    or $bg    = 7;
+   defined $tabfg or $tabfg = 12;
+   defined $tabbg or $tabbg = 0;

    $self->{rs_tabbar} = urxvt::SET_COLOR (urxvt::DEFAULT_RSTYLE, $fg    + 2, $bg    + 2);
    $self->{rs_tab}    = urxvt::SET_COLOR (urxvt::DEFAULT_RSTYLE, $tabfg + 2, $tabbg + 2);
@@ -333,7 +333,12 @@ sub tab_key_press {
          $self->make_current ($self->{tabs}[$idx2]);

          return 1;
-      }
+      } elsif ($keysym > 48 && $keysym < 58) {
+         my ($idx) = $keysym - 49;
+         $self->make_current ($self->{tabs}[$idx]) if $self->{tabs}[$idx] != $tab and $idx < @{ $self->{tabs}};
+
+         return 1;
+         }
    }

    ()
Attachment: 

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.