Hi List,

I have here a small hack for the tabbed extension, which some people
expressed interest in.  I therefore think it might be of general interest.

I like the tabbed extension but find the tab titles ("1", "2", ...)
confusing at times.  On the other hand, my shell prompt updates my
window title to contain the current path etc.  I would like to have this
information in the tab titles like so:

Current look of the tab bar:
     "[New] | 1 | 2 |"
New look:
     "[New] | ...ork/examples | ...:~/src/abc/tex |"

I added a resource to configure the maxium length for the tab titles.
Always the right side of the string is shown, assuming it carries the
most meaning.

The patch is a bit hacky but explains my idea.  I appreciate feedback.

Cheers,
Martin
--- /usr/lib/urxvt/perl/tabbed  2008-06-25 10:35:47.000000000 +0200
+++ tabbed      2008-07-30 13:55:53.000000000 +0200
@@ -5,8 +5,9 @@
 
    my $ncol = $self->ncol;
 
-   my $text = " " x $ncol;
-   my $rend = [($self->{rs_tabbar}) x $ncol];
+   my $text   = " " x $ncol;
+   my $rend   = [($self->{rs_tabbar}) x $ncol];
+   my $tablen = $self->{rs_tablen};
 
    my @ofs;
 
@@ -23,7 +24,18 @@
       my $act = $tab->{activity} && $tab != $self->{cur}
                 ? "*" : " ";
 
-      my $txt = "$act$idx$act";
+      # fixme: where are perl symbols for WM_NAME from xatom.h?
+      my ($dummy1, $dummy2, $val) =
+          $self->XGetWindowProperty ($tab->parent, 39);
+
+      $val =  $self->locale_decode($val); # why is this necessary?
+      if (length($val) > $tablen)
+      {
+          # what if the user doesn't use a unicode locale?
+          $val = chr(0x2026).substr($val, length($val) - $tablen, $tablen);
+      }
+
+      my $txt = "$act${val}$act";
       my $len = length $txt;
 
       substr $text, $ofs, $len + 1, "$txt|";
@@ -219,18 +231,21 @@
 
    $self->option ($urxvt::OPTION{scrollBar}, 0);
 
-   my $fg    = $self->x_resource ("tabbar-fg");
-   my $bg    = $self->x_resource ("tabbar-bg");
-   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;
+   my $fg     = $self->x_resource ("tabbar-fg");
+   my $bg     = $self->x_resource ("tabbar-bg");
+   my $tabfg  = $self->x_resource ("tab-fg");
+   my $tabbg  = $self->x_resource ("tab-bg");
+   my $tablen = $self->x_resource ("tablen");
+
+   defined $fg     or $fg     = 3;
+   defined $bg     or $bg     = 0;
+   defined $tabfg  or $tabfg  = 0;
+   defined $tabbg  or $tabbg  = 1;
+   defined $tablen or $tablen = 15;
 
    $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);
+   $self->{rs_tablen} = $tablen;
 
    ()
 }
@@ -345,6 +360,8 @@
    $self->copy_properties
       if $event->{window} == $tab->parent;
 
+   $self->refresh;  # care for tab name changes, this may do too much work?
+
    ()
 }
 
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to