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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines