ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/tabbed
(Generate patch)

Comparing rxvt-unicode/src/perl/tabbed (file contents):
Revision 1.7 by root, Fri Jan 20 15:40:39 2006 UTC vs.
Revision 1.9 by root, Fri Jan 20 16:13:33 2006 UTC

18 my $idx = 0; 18 my $idx = 0;
19 19
20 for my $tab (@{ $self->{tabs} }) { 20 for my $tab (@{ $self->{tabs} }) {
21 $idx++; 21 $idx++;
22 22
23 my $act = $tab->{activity} && $tab != $self->{cur}
24 ? "*" : " ";
25
23 my $txt = " $idx "; 26 my $txt = "$act$idx$act";
24 my $len = length $txt; 27 my $len = length $txt;
25 28
26 substr $text, $ofs, $len + 1, "$txt|"; 29 substr $text, $ofs, $len + 1, "$txt|";
27 @$rend[$ofs .. $ofs + $len - 1] = (urxvt::OVERLAY_RSTYLE) x $len 30 @$rend[$ofs .. $ofs + $len - 1] = (urxvt::OVERLAY_RSTYLE) x $len
28 if $tab == $self->{cur}; 31 if $tab == $self->{cur};
96 99
97sub make_current { 100sub make_current {
98 my ($self, $tab) = @_; 101 my ($self, $tab) = @_;
99 102
100 if (my $cur = $self->{cur}) { 103 if (my $cur = $self->{cur}) {
104 delete $cur->{activity};
101 $cur->XUnmapWindow ($cur->parent) if $cur->mapped; 105 $cur->XUnmapWindow ($cur->parent) if $cur->mapped;
102 $cur->focus_out; 106 $cur->focus_out;
103 } 107 }
104 108
105 $self->{cur} = $tab; 109 $self->{cur} = $tab;
106 110
107 $self->configure; 111 $self->configure;
108 $tab->focus_in; 112 $tab->focus_in;
109 $tab->XMapWindow ($tab->parent); 113 $tab->XMapWindow ($tab->parent);
110 $self->refresh; 114 $self->refresh;
115 delete $tab->{activity};
111 116
112 () 117 ()
113} 118}
114 119
115sub on_button_press { 120sub on_button_press {
208 } 213 }
209 214
210 () 215 ()
211} 216}
212 217
218sub tab_key_press {
219 my ($self, $tab, $event, $keysym, $str) = @_;
220
221 if ($event->{state} & urxvt::ShiftMask
222 && ($keysym == 0xff51 || $keysym == 0xff53)) {
223 my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
224
225 --$idx if $keysym == 0xff51;
226 ++$idx if $keysym == 0xff53;
227
228 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
229 $self->refresh;
230
231 return 1;
232 }
233
234 ()
235}
236
237sub tab_activity {
238 my ($self, $tab) = @_;
239
240 $self->refresh;
241}
242
213package urxvt::ext::tabbed::tab; 243package urxvt::ext::tabbed::tab;
214 244
215# helper extension implementing the subwindows of a tabbed terminal. 245# helper extension implementing the subwindows of a tabbed terminal.
216# simply proxies all interesting calls back to the tabbed class. 246# simply proxies all interesting calls back to the tabbed class.
217 247
218{ 248{
219 for my $hook qw(start destroy) { 249 for my $hook qw(start destroy key_press) {
220 eval qq{ 250 eval qq{
221 sub on_$hook { 251 sub on_$hook {
222 my \$parent = \$_[0]{term}{parent} 252 my \$parent = \$_[0]{term}{parent}
223 or return; 253 or return;
224 \$parent->tab_$hook (\@_) 254 \$parent->tab_$hook (\@_)
226 }; 256 };
227 die if $@; 257 die if $@;
228 } 258 }
229} 259}
230 260
261sub on_add_lines {
262 $_[0]->{activity}++
263 or $_[0]{term}{parent}->tab_activity ($_[0]);
264 ()
265}
231 266
232 267

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines