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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines