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.26 by sf-exg, Mon Sep 26 10:12:30 2011 UTC vs.
Revision 1.38 by sf-exg, Fri Jan 16 20:13:01 2015 UTC

1#! perl 1#! perl
2
3#:META:RESOURCE:tabbar-fg:colour:tab bar foreground colour
4#:META:RESOURCE:tabbar-bg:colour:tab bar background colour
5#:META:RESOURCE:tab-fg:colour:tab foreground colour
6#:META:RESOURCE:tab-bg:colour:tab background colour
7
8=head1 NAME
9
10tabbed - tabbed interface to urxvt
11
12=head1 DESCRIPTION
13
14This transforms the terminal into a tabbar with additional terminals, that
15is, it implements what is commonly referred to as "tabbed terminal". The topmost line
16displays a "[NEW]" button, which, when clicked, will add a new tab, followed by one
17button per tab.
18
19Clicking a button will activate that tab. Pressing B<Shift-Left> and
20B<Shift-Right> will switch to the tab left or right of the current one,
21while B<Shift-Down> creates a new tab. Pressing B<Ctrl-Left> and
22B<Ctrl-Right> will renumber the current tab by moving it to the left or
23to the right.
24
25The tabbar itself can be configured similarly to a normal terminal, but
26with a resource class of C<URxvt.tabbed>. In addition, it supports the
27following four resources (shown with defaults):
28
29 URxvt.tabbed.tabbar-fg: <colour-index, default 3>
30 URxvt.tabbed.tabbar-bg: <colour-index, default 0>
31 URxvt.tabbed.tab-fg: <colour-index, default 0>
32 URxvt.tabbed.tab-bg: <colour-index, default 1>
33
34See I<COLOR AND GRAPHICS> in the @@RXVT_NAME@@(1) manpage for valid
35indices.
36
37=cut
2 38
3sub refresh { 39sub refresh {
4 my ($self) = @_; 40 my ($self) = @_;
5 41
6 my $ncol = $self->ncol; 42 my $ncol = $self->ncol;
43 $self->want_refresh; 79 $self->want_refresh;
44} 80}
45 81
46sub new_tab { 82sub new_tab {
47 my ($self, @argv) = @_; 83 my ($self, @argv) = @_;
48
49 my $offset = $self->fheight;
50 84
51 # save a backlink to us, make sure tabbed is inactive 85 # save a backlink to us, make sure tabbed is inactive
52 push @urxvt::TERM_INIT, sub { 86 push @urxvt::TERM_INIT, sub {
53 my ($term) = @_; 87 my ($term) = @_;
54 $term->{parent} = $self; 88 $term->{parent} = $self;
105 my $current = delete $self->{current_properties}; 139 my $current = delete $self->{current_properties};
106 140
107 # pass 1: copy over properties different or nonexisting 141 # pass 1: copy over properties different or nonexisting
108 for my $atom ($tab->XListProperties ($tab->parent)) { 142 for my $atom ($tab->XListProperties ($tab->parent)) {
109 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); 143 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
110 144
111 # fix up size hints 145 # fix up size hints
112 if ($atom == $wm_normal_hints) { 146 if ($atom == $wm_normal_hints) {
113 my (@hints) = unpack "l!*", $items; 147 my (@hints) = unpack "l!*", $items;
114 148
115 $hints[$_] += $self->{tabheight} for (4, 6, 16); 149 $hints[$_] += $self->{tabheight} for (4, 6, 16);
116 150
117 $items = pack "l!*", @hints; 151 $items = pack "l!*", @hints;
118 } 152 }
119 153
120 my $cur = delete $current->{$atom}; 154 my $cur = delete $current->{$atom};
121 155
136 if (my $cur = $self->{cur}) { 170 if (my $cur = $self->{cur}) {
137 delete $cur->{activity}; 171 delete $cur->{activity};
138 $cur->XUnmapWindow ($cur->parent) if $cur->mapped; 172 $cur->XUnmapWindow ($cur->parent) if $cur->mapped;
139 $cur->focus_out; 173 $cur->focus_out;
140 } 174 }
141 175
142 $self->{cur} = $tab; 176 $self->{cur} = $tab;
143 177
144 $self->configure; 178 $self->configure;
145 $self->copy_properties; 179 $self->copy_properties;
146 180
147 $tab->focus_out; # just in case, should be a nop 181 $tab->focus_out; # just in case, should be a nop
148 $tab->focus_in if $self->focus; 182 $tab->focus_in if $self->focus;
149 183
150 $tab->XMapWindow ($tab->parent); 184 $tab->XMapWindow ($tab->parent);
151 delete $tab->{activity}; 185 delete $tab->{activity};
152 $self->refresh; 186 $self->refresh;
153 187
154 () 188 ()
180 214
181sub on_key_press { 215sub on_key_press {
182 my ($self, $event) = @_; 216 my ($self, $event) = @_;
183 217
184 $self->{cur}->key_press ($event->{state}, $event->{keycode}, $event->{time}); 218 $self->{cur}->key_press ($event->{state}, $event->{keycode}, $event->{time});
219 $self->{cur}->refresh_check;
185 220
186 1 221 1
187} 222}
188 223
189sub on_key_release { 224sub on_key_release {
190 my ($self, $event) = @_; 225 my ($self, $event) = @_;
191 226
192 $self->{cur}->key_release ($event->{state}, $event->{keycode}, $event->{time}); 227 $self->{cur}->key_release ($event->{state}, $event->{keycode}, $event->{time});
228 $self->{cur}->refresh_check;
193 229
194 1 230 1
195} 231}
196 232
197sub on_button_press { 233sub on_button_press {
320 356
321 --$idx if $keysym == 0xff51; 357 --$idx if $keysym == 0xff51;
322 ++$idx if $keysym == 0xff53; 358 ++$idx if $keysym == 0xff53;
323 359
324 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); 360 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
325 361
326 return 1; 362 return 1;
327 } elsif ($keysym == 0xff54) { 363 } elsif ($keysym == 0xff54) {
328 $self->new_tab; 364 $self->new_tab;
329 365
330 return 1; 366 return 1;
366 402
367# helper extension implementing the subwindows of a tabbed terminal. 403# helper extension implementing the subwindows of a tabbed terminal.
368# simply proxies all interesting calls back to the tabbed class. 404# simply proxies all interesting calls back to the tabbed class.
369 405
370{ 406{
371 for my $hook qw(start destroy key_press property_notify) { 407 for my $hook (qw(start destroy key_press property_notify)) {
372 eval qq{ 408 eval qq{
373 sub on_$hook { 409 sub on_$hook {
374 my \$parent = \$_[0]{term}{parent} 410 my \$parent = \$_[0]{term}{parent}
375 or return; 411 or return;
376 \$parent->tab_$hook (\@_) 412 \$parent->tab_$hook (\@_)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines