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.8 by root, Fri Jan 20 15:47:55 2006 UTC vs.
Revision 1.11 by root, Fri Jan 20 18:50:49 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};
73 $tab->XMoveResizeWindow ( 76 $tab->XMoveResizeWindow (
74 $tab->parent, 77 $tab->parent,
75 0, $self->{tabheight}, 78 0, $self->{tabheight},
76 $self->width, $self->height - $self->{tabheight} 79 $self->width, $self->height - $self->{tabheight}
77 ); 80 );
81}
82
83sub copy_properties {
84 my ($self) = @_;
85 my $tab = $self->{cur};
78 86
79 my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS"); 87 my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS");
88
89 my %our_props = map +($_ => undef), $self->XListProperties ($self->parent);
80 90
81 for my $atom ($tab->XListProperties ($tab->parent)) { 91 for my $atom ($tab->XListProperties ($tab->parent)) {
82 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); 92 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
93
94 delete $our_props{$atom};
83 95
84 if ($atom == $wm_normal_hints) { 96 if ($atom == $wm_normal_hints) {
85 my (@hints) = unpack "l!*", $items; 97 my (@hints) = unpack "l!*", $items;
86 98
87 $hints[$_] += $self->{tabheight} for (4, 6, 16); 99 $hints[$_] += $self->{tabheight} for (4, 6, 16);
89 $items = pack "l!*", @hints; 101 $items = pack "l!*", @hints;
90 } 102 }
91 $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items); 103 $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items);
92 } 104 }
93 105
94 $self->refresh; 106 $self->XDeleteProperty ($self->parent, $_) for keys %our_props;
95} 107}
96 108
97sub make_current { 109sub make_current {
98 my ($self, $tab) = @_; 110 my ($self, $tab) = @_;
99 111
100 if (my $cur = $self->{cur}) { 112 if (my $cur = $self->{cur}) {
113 delete $cur->{activity};
101 $cur->XUnmapWindow ($cur->parent) if $cur->mapped; 114 $cur->XUnmapWindow ($cur->parent) if $cur->mapped;
102 $cur->focus_out; 115 $cur->focus_out;
103 } 116 }
104 117
105 $self->{cur} = $tab; 118 $self->{cur} = $tab;
106 119
107 $self->configure; 120 $self->configure;
121 $self->copy_properties;
108 $tab->focus_in; 122 $tab->focus_in;
109 $tab->XMapWindow ($tab->parent); 123 $tab->XMapWindow ($tab->parent);
124 delete $tab->{activity};
110 $self->refresh; 125 $self->refresh;
111 126
112 () 127 ()
113} 128}
114 129
179 1 194 1
180} 195}
181 196
182sub tab_start { 197sub tab_start {
183 my ($self, $tab) = @_; 198 my ($self, $tab) = @_;
199
200 $tab->XChangeInput ($tab->parent, urxvt::PropertyChangeMask);
184 201
185 push @{ $self->{tabs} }, $tab; 202 push @{ $self->{tabs} }, $tab;
186 203
187# $tab->{name} ||= scalar @{ $self->{tabs} }; 204# $tab->{name} ||= scalar @{ $self->{tabs} };
188 $self->make_current ($tab); 205 $self->make_current ($tab);
211} 228}
212 229
213sub tab_key_press { 230sub tab_key_press {
214 my ($self, $tab, $event, $keysym, $str) = @_; 231 my ($self, $tab, $event, $keysym, $str) = @_;
215 232
216 if ($event->{state} & urxvt::ShiftMask 233 if ($event->{state} & urxvt::ShiftMask) {
217 && ($keysym == 0xff51 || $keysym == 0xff53)) { 234 if ($keysym == 0xff51 || $keysym == 0xff53) {
218 my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} }; 235 my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
219 236
220 --$idx if $keysym == 0xff51; 237 --$idx if $keysym == 0xff51;
221 ++$idx if $keysym == 0xff53; 238 ++$idx if $keysym == 0xff53;
222 239
223 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); 240 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
224 $self->refresh; 241
242 return 1;
243 } elsif ($keysym == 0xff54) {
244 $self->new_tab;
245
246 return 1;
225 247 }
226 return 1;
227 } 248 }
228 249
229 () 250 ()
251}
252
253sub tab_property_notify {
254 my ($self, $tab, $event) = @_;
255
256 $self->copy_properties
257 if $event->{window} == $tab->parent;
258
259 ()
260}
261
262sub tab_activity {
263 my ($self, $tab) = @_;
264
265 $self->refresh;
230} 266}
231 267
232package urxvt::ext::tabbed::tab; 268package urxvt::ext::tabbed::tab;
233 269
234# helper extension implementing the subwindows of a tabbed terminal. 270# helper extension implementing the subwindows of a tabbed terminal.
235# simply proxies all interesting calls back to the tabbed class. 271# simply proxies all interesting calls back to the tabbed class.
236 272
237{ 273{
238 for my $hook qw(start destroy key_press) { 274 for my $hook qw(start destroy key_press property_notify) {
239 eval qq{ 275 eval qq{
240 sub on_$hook { 276 sub on_$hook {
241 my \$parent = \$_[0]{term}{parent} 277 my \$parent = \$_[0]{term}{parent}
242 or return; 278 or return;
243 \$parent->tab_$hook (\@_) 279 \$parent->tab_$hook (\@_)
245 }; 281 };
246 die if $@; 282 die if $@;
247 } 283 }
248} 284}
249 285
286sub on_add_lines {
287 $_[0]->{activity}++
288 or $_[0]{term}{parent}->tab_activity ($_[0]);
289 ()
290}
250 291
251 292

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines