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.24 by root, Sun Jun 15 14:07:58 2008 UTC vs.
Revision 1.35 by root, Tue Sep 4 22:41:12 2012 UTC

1#! perl 1#! perl
2
3#:META:X_RESOURCE:tabbar-fg:colour:tab bar foreground colour
4#:META:X_RESOURCE:tabbar-bg:colour:tab bar background colour
5#:META:X_RESOURCE:tab-fg:colour:tab foreground colour
6#:META:X_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;
55 89
56 $term->resource ($_->[0] => $_->[1]) 90 for (0 .. urxvt::NUM_RESOURCES - 1) {
57 for @{ $self->{resource} || [] }; 91 my $value = $self->{resource}[$_];
92
93 $term->resource ("+$_" => $value)
94 if defined $value;
95 }
58 96
59 $term->resource (perl_ext_2 => $term->resource ("perl_ext_2") . ",-tabbed"); 97 $term->resource (perl_ext_2 => $term->resource ("perl_ext_2") . ",-tabbed");
60 }; 98 };
61 99
62 push @urxvt::TERM_EXT, urxvt::ext::tabbed::tab::; 100 push @urxvt::TERM_EXT, urxvt::ext::tabbed::tab::;
101 my $current = delete $self->{current_properties}; 139 my $current = delete $self->{current_properties};
102 140
103 # pass 1: copy over properties different or nonexisting 141 # pass 1: copy over properties different or nonexisting
104 for my $atom ($tab->XListProperties ($tab->parent)) { 142 for my $atom ($tab->XListProperties ($tab->parent)) {
105 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); 143 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
106 144
107 # fix up size hints 145 # fix up size hints
108 if ($atom == $wm_normal_hints) { 146 if ($atom == $wm_normal_hints) {
109 my (@hints) = unpack "l!*", $items; 147 my (@hints) = unpack "l!*", $items;
110 148
111 $hints[$_] += $self->{tabheight} for (4, 6, 16); 149 $hints[$_] += $self->{tabheight} for (4, 6, 16);
112 150
113 $items = pack "l!*", @hints; 151 $items = pack "l!*", @hints;
114 } 152 }
115 153
116 my $cur = delete $current->{$atom}; 154 my $cur = delete $current->{$atom};
117 155
132 if (my $cur = $self->{cur}) { 170 if (my $cur = $self->{cur}) {
133 delete $cur->{activity}; 171 delete $cur->{activity};
134 $cur->XUnmapWindow ($cur->parent) if $cur->mapped; 172 $cur->XUnmapWindow ($cur->parent) if $cur->mapped;
135 $cur->focus_out; 173 $cur->focus_out;
136 } 174 }
137 175
138 $self->{cur} = $tab; 176 $self->{cur} = $tab;
139 177
140 $self->configure; 178 $self->configure;
141 $self->copy_properties; 179 $self->copy_properties;
142 180
143 $tab->focus_out; # just in case, should be a nop 181 $tab->focus_out; # just in case, should be a nop
144 $tab->focus_in if $self->focus; 182 $tab->focus_in if $self->focus;
145 183
146 $tab->XMapWindow ($tab->parent); 184 $tab->XMapWindow ($tab->parent);
147 delete $tab->{activity}; 185 delete $tab->{activity};
148 $self->refresh; 186 $self->refresh;
149 187
150 () 188 ()
162 my ($self, $event) = @_; 200 my ($self, $event) = @_;
163 201
164 $self->{cur}->focus_out; 202 $self->{cur}->focus_out;
165 203
166 () 204 ()
205}
206
207sub on_tt_write {
208 my ($self, $octets) = @_;
209
210 $self->{cur}->tt_write ($octets);
211
212 1
167} 213}
168 214
169sub on_key_press { 215sub on_key_press {
170 my ($self, $event) = @_; 216 my ($self, $event) = @_;
171 217
205} 251}
206 252
207sub on_init { 253sub on_init {
208 my ($self) = @_; 254 my ($self) = @_;
209 255
210 for (qw(name chdir perl_ext_1 perl_ext_2)) { 256 $self->{resource} = [map $self->resource ("+$_"), 0 .. urxvt::NUM_RESOURCES - 1];
211 my $val = $self->resource ($_);
212
213 push @{ $self->{resource} }, [$_ => $val]
214 if defined $val;
215 }
216 257
217 $self->resource (int_bwidth => 0); 258 $self->resource (int_bwidth => 0);
218 $self->resource (name => "URxvt.tabbed"); 259 $self->resource (name => "URxvt.tabbed");
219 $self->resource (pty_fd => -1); 260 $self->resource (pty_fd => -1);
220 261
313 354
314 --$idx if $keysym == 0xff51; 355 --$idx if $keysym == 0xff51;
315 ++$idx if $keysym == 0xff53; 356 ++$idx if $keysym == 0xff53;
316 357
317 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); 358 $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
318 359
319 return 1; 360 return 1;
320 } elsif ($keysym == 0xff54) { 361 } elsif ($keysym == 0xff54) {
321 $self->new_tab; 362 $self->new_tab;
322 363
323 return 1; 364 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines