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.12 by root, Sun Jan 22 12:21:27 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
165 180
166sub on_configure_notify { 181sub on_configure_notify {
167 my ($self, $event) = @_; 182 my ($self, $event) = @_;
168 183
169 $self->configure; 184 $self->configure;
185 $self->refresh;
170 186
171 () 187 ()
172} 188}
173 189
174sub on_wm_delete_window { 190sub on_wm_delete_window {
179 1 195 1
180} 196}
181 197
182sub tab_start { 198sub tab_start {
183 my ($self, $tab) = @_; 199 my ($self, $tab) = @_;
200
201 $tab->XChangeInput ($tab->parent, urxvt::PropertyChangeMask);
184 202
185 push @{ $self->{tabs} }, $tab; 203 push @{ $self->{tabs} }, $tab;
186 204
187# $tab->{name} ||= scalar @{ $self->{tabs} }; 205# $tab->{name} ||= scalar @{ $self->{tabs} };
188 $self->make_current ($tab); 206 $self->make_current ($tab);
211} 229}
212 230
213sub tab_key_press { 231sub tab_key_press {
214 my ($self, $tab, $event, $keysym, $str) = @_; 232 my ($self, $tab, $event, $keysym, $str) = @_;
215 233
216 if ($event->{state} & urxvt::ShiftMask 234 if ($event->{state} & urxvt::ShiftMask) {
217 && ($keysym == 0xff51 || $keysym == 0xff53)) { 235 if ($keysym == 0xff51 || $keysym == 0xff53) {
218 my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} }; 236 my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
219 237
220 --$idx if $keysym == 0xff51; 238 --$idx if $keysym == 0xff51;
221 ++$idx if $keysym == 0xff53; 239 ++$idx if $keysym == 0xff53;
222 240
223 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); 241 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
224 $self->refresh; 242
243 return 1;
244 } elsif ($keysym == 0xff54) {
245 $self->new_tab;
246
247 return 1;
225 248 }
226 return 1;
227 } 249 }
228 250
229 () 251 ()
252}
253
254sub tab_property_notify {
255 my ($self, $tab, $event) = @_;
256
257 $self->copy_properties
258 if $event->{window} == $tab->parent;
259
260 ()
261}
262
263sub tab_activity {
264 my ($self, $tab) = @_;
265
266 $self->refresh;
230} 267}
231 268
232package urxvt::ext::tabbed::tab; 269package urxvt::ext::tabbed::tab;
233 270
234# helper extension implementing the subwindows of a tabbed terminal. 271# helper extension implementing the subwindows of a tabbed terminal.
235# simply proxies all interesting calls back to the tabbed class. 272# simply proxies all interesting calls back to the tabbed class.
236 273
237{ 274{
238 for my $hook qw(start destroy key_press) { 275 for my $hook qw(start destroy key_press property_notify) {
239 eval qq{ 276 eval qq{
240 sub on_$hook { 277 sub on_$hook {
241 my \$parent = \$_[0]{term}{parent} 278 my \$parent = \$_[0]{term}{parent}
242 or return; 279 or return;
243 \$parent->tab_$hook (\@_) 280 \$parent->tab_$hook (\@_)
245 }; 282 };
246 die if $@; 283 die if $@;
247 } 284 }
248} 285}
249 286
287sub on_add_lines {
288 $_[0]->{activity}++
289 or $_[0]{term}{parent}->tab_activity ($_[0]);
290 ()
291}
250 292
251 293

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines