… | |
… | |
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 | |
97 | sub make_current { |
100 | sub 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); |
|
|
114 | delete $tab->{activity}; |
110 | $self->refresh; |
115 | $self->refresh; |
111 | |
116 | |
112 | () |
117 | () |
113 | } |
118 | } |
114 | |
119 | |
… | |
… | |
208 | } |
213 | } |
209 | |
214 | |
210 | () |
215 | () |
211 | } |
216 | } |
212 | |
217 | |
|
|
218 | sub tab_key_press { |
|
|
219 | my ($self, $tab, $event, $keysym, $str) = @_; |
|
|
220 | |
|
|
221 | if ($event->{state} & urxvt::ShiftMask) { |
|
|
222 | if ($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 | |
|
|
230 | return 1; |
|
|
231 | } elsif ($keysym == 0xff54) { |
|
|
232 | $self->new_tab; |
|
|
233 | |
|
|
234 | return 1; |
|
|
235 | } |
|
|
236 | } |
|
|
237 | |
|
|
238 | () |
|
|
239 | } |
|
|
240 | |
|
|
241 | sub tab_activity { |
|
|
242 | my ($self, $tab) = @_; |
|
|
243 | |
|
|
244 | $self->refresh; |
|
|
245 | } |
|
|
246 | |
213 | package urxvt::ext::tabbed::tab; |
247 | package urxvt::ext::tabbed::tab; |
214 | |
248 | |
215 | # helper extension implementing the subwindows of a tabbed terminal. |
249 | # helper extension implementing the subwindows of a tabbed terminal. |
216 | # simply proxies all interesting calls back to the tabbed class. |
250 | # simply proxies all interesting calls back to the tabbed class. |
217 | |
251 | |
218 | { |
252 | { |
219 | for my $hook qw(start destroy) { |
253 | for my $hook qw(start destroy key_press) { |
220 | eval qq{ |
254 | eval qq{ |
221 | sub on_$hook { |
255 | sub on_$hook { |
222 | my \$parent = \$_[0]{term}{parent} |
256 | my \$parent = \$_[0]{term}{parent} |
223 | or return; |
257 | or return; |
224 | \$parent->tab_$hook (\@_) |
258 | \$parent->tab_$hook (\@_) |
… | |
… | |
226 | }; |
260 | }; |
227 | die if $@; |
261 | die if $@; |
228 | } |
262 | } |
229 | } |
263 | } |
230 | |
264 | |
|
|
265 | sub on_add_lines { |
|
|
266 | $_[0]->{activity}++ |
|
|
267 | or $_[0]{term}{parent}->tab_activity ($_[0]); |
|
|
268 | () |
|
|
269 | } |
231 | |
270 | |
232 | |
271 | |