--- rxvt-unicode/src/perl/tabbed 2006/01/20 15:47:55 1.8 +++ rxvt-unicode/src/perl/tabbed 2006/01/20 18:50:49 1.11 @@ -20,7 +20,10 @@ for my $tab (@{ $self->{tabs} }) { $idx++; - my $txt = " $idx "; + my $act = $tab->{activity} && $tab != $self->{cur} + ? "*" : " "; + + my $txt = "$act$idx$act"; my $len = length $txt; substr $text, $ofs, $len + 1, "$txt|"; @@ -75,11 +78,20 @@ 0, $self->{tabheight}, $self->width, $self->height - $self->{tabheight} ); +} + +sub copy_properties { + my ($self) = @_; + my $tab = $self->{cur}; my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS"); + my %our_props = map +($_ => undef), $self->XListProperties ($self->parent); + for my $atom ($tab->XListProperties ($tab->parent)) { my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); + + delete $our_props{$atom}; if ($atom == $wm_normal_hints) { my (@hints) = unpack "l!*", $items; @@ -91,13 +103,14 @@ $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items); } - $self->refresh; + $self->XDeleteProperty ($self->parent, $_) for keys %our_props; } sub make_current { my ($self, $tab) = @_; if (my $cur = $self->{cur}) { + delete $cur->{activity}; $cur->XUnmapWindow ($cur->parent) if $cur->mapped; $cur->focus_out; } @@ -105,8 +118,10 @@ $self->{cur} = $tab; $self->configure; + $self->copy_properties; $tab->focus_in; $tab->XMapWindow ($tab->parent); + delete $tab->{activity}; $self->refresh; () @@ -182,6 +197,8 @@ sub tab_start { my ($self, $tab) = @_; + $tab->XChangeInput ($tab->parent, urxvt::PropertyChangeMask); + push @{ $self->{tabs} }, $tab; # $tab->{name} ||= scalar @{ $self->{tabs} }; @@ -213,29 +230,48 @@ sub tab_key_press { my ($self, $tab, $event, $keysym, $str) = @_; - if ($event->{state} & urxvt::ShiftMask - && ($keysym == 0xff51 || $keysym == 0xff53)) { - my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} }; + if ($event->{state} & urxvt::ShiftMask) { + if ($keysym == 0xff51 || $keysym == 0xff53) { + my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} }; + + --$idx if $keysym == 0xff51; + ++$idx if $keysym == 0xff53; + + $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); + + return 1; + } elsif ($keysym == 0xff54) { + $self->new_tab; - --$idx if $keysym == 0xff51; - ++$idx if $keysym == 0xff53; - - $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); - $self->refresh; - - return 1; + return 1; + } } () } +sub tab_property_notify { + my ($self, $tab, $event) = @_; + + $self->copy_properties + if $event->{window} == $tab->parent; + + () +} + +sub tab_activity { + my ($self, $tab) = @_; + + $self->refresh; +} + package urxvt::ext::tabbed::tab; # helper extension implementing the subwindows of a tabbed terminal. # simply proxies all interesting calls back to the tabbed class. { - for my $hook qw(start destroy key_press) { + for my $hook qw(start destroy key_press property_notify) { eval qq{ sub on_$hook { my \$parent = \$_[0]{term}{parent} @@ -247,5 +283,10 @@ } } +sub on_add_lines { + $_[0]->{activity}++ + or $_[0]{term}{parent}->tab_activity ($_[0]); + () +}