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 | |
|
|
10 | tabbed - tabbed interface to urxvt |
|
|
11 | |
|
|
12 | =head1 DESCRIPTION |
|
|
13 | |
|
|
14 | This transforms the terminal into a tabbar with additional terminals, that |
|
|
15 | is, it implements what is commonly referred to as "tabbed terminal". The topmost line |
|
|
16 | displays a "[NEW]" button, which, when clicked, will add a new tab, followed by one |
|
|
17 | button per tab. |
|
|
18 | |
|
|
19 | Clicking a button will activate that tab. Pressing B<Shift-Left> and |
|
|
20 | B<Shift-Right> will switch to the tab left or right of the current one, |
|
|
21 | while B<Shift-Down> creates a new tab. |
|
|
22 | |
|
|
23 | The tabbar itself can be configured similarly to a normal terminal, but |
|
|
24 | with a resource class of C<URxvt.tabbed>. In addition, it supports the |
|
|
25 | following four resources (shown with defaults): |
|
|
26 | |
|
|
27 | URxvt.tabbed.tabbar-fg: <colour-index, default 3> |
|
|
28 | URxvt.tabbed.tabbar-bg: <colour-index, default 0> |
|
|
29 | URxvt.tabbed.tab-fg: <colour-index, default 0> |
|
|
30 | URxvt.tabbed.tab-bg: <colour-index, default 1> |
|
|
31 | |
|
|
32 | See I<COLOR AND GRAPHICS> in the @@RXVT_NAME@@(1) manpage for valid |
|
|
33 | indices. |
|
|
34 | |
|
|
35 | =cut |
2 | |
36 | |
3 | sub refresh { |
37 | sub refresh { |
4 | my ($self) = @_; |
38 | my ($self) = @_; |
5 | |
39 | |
6 | my $ncol = $self->ncol; |
40 | my $ncol = $self->ncol; |
… | |
… | |
43 | $self->want_refresh; |
77 | $self->want_refresh; |
44 | } |
78 | } |
45 | |
79 | |
46 | sub new_tab { |
80 | sub new_tab { |
47 | my ($self, @argv) = @_; |
81 | my ($self, @argv) = @_; |
48 | |
|
|
49 | my $offset = $self->fheight; |
|
|
50 | |
82 | |
51 | # save a backlink to us, make sure tabbed is inactive |
83 | # save a backlink to us, make sure tabbed is inactive |
52 | push @urxvt::TERM_INIT, sub { |
84 | push @urxvt::TERM_INIT, sub { |
53 | my ($term) = @_; |
85 | my ($term) = @_; |
54 | $term->{parent} = $self; |
86 | $term->{parent} = $self; |
… | |
… | |
105 | my $current = delete $self->{current_properties}; |
137 | my $current = delete $self->{current_properties}; |
106 | |
138 | |
107 | # pass 1: copy over properties different or nonexisting |
139 | # pass 1: copy over properties different or nonexisting |
108 | for my $atom ($tab->XListProperties ($tab->parent)) { |
140 | for my $atom ($tab->XListProperties ($tab->parent)) { |
109 | my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); |
141 | my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); |
110 | |
142 | |
111 | # fix up size hints |
143 | # fix up size hints |
112 | if ($atom == $wm_normal_hints) { |
144 | if ($atom == $wm_normal_hints) { |
113 | my (@hints) = unpack "l!*", $items; |
145 | my (@hints) = unpack "l!*", $items; |
114 | |
146 | |
115 | $hints[$_] += $self->{tabheight} for (4, 6, 16); |
147 | $hints[$_] += $self->{tabheight} for (4, 6, 16); |
116 | |
148 | |
117 | $items = pack "l!*", @hints; |
149 | $items = pack "l!*", @hints; |
118 | } |
150 | } |
119 | |
151 | |
120 | my $cur = delete $current->{$atom}; |
152 | my $cur = delete $current->{$atom}; |
121 | |
153 | |
… | |
… | |
136 | if (my $cur = $self->{cur}) { |
168 | if (my $cur = $self->{cur}) { |
137 | delete $cur->{activity}; |
169 | delete $cur->{activity}; |
138 | $cur->XUnmapWindow ($cur->parent) if $cur->mapped; |
170 | $cur->XUnmapWindow ($cur->parent) if $cur->mapped; |
139 | $cur->focus_out; |
171 | $cur->focus_out; |
140 | } |
172 | } |
141 | |
173 | |
142 | $self->{cur} = $tab; |
174 | $self->{cur} = $tab; |
143 | |
175 | |
144 | $self->configure; |
176 | $self->configure; |
145 | $self->copy_properties; |
177 | $self->copy_properties; |
146 | |
178 | |
147 | $tab->focus_out; # just in case, should be a nop |
179 | $tab->focus_out; # just in case, should be a nop |
148 | $tab->focus_in if $self->focus; |
180 | $tab->focus_in if $self->focus; |
149 | |
181 | |
150 | $tab->XMapWindow ($tab->parent); |
182 | $tab->XMapWindow ($tab->parent); |
151 | delete $tab->{activity}; |
183 | delete $tab->{activity}; |
152 | $self->refresh; |
184 | $self->refresh; |
153 | |
185 | |
154 | () |
186 | () |
… | |
… | |
166 | my ($self, $event) = @_; |
198 | my ($self, $event) = @_; |
167 | |
199 | |
168 | $self->{cur}->focus_out; |
200 | $self->{cur}->focus_out; |
169 | |
201 | |
170 | () |
202 | () |
|
|
203 | } |
|
|
204 | |
|
|
205 | sub on_tt_write { |
|
|
206 | my ($self, $octets) = @_; |
|
|
207 | |
|
|
208 | $self->{cur}->tt_write ($octets); |
|
|
209 | |
|
|
210 | 1 |
171 | } |
211 | } |
172 | |
212 | |
173 | sub on_key_press { |
213 | sub on_key_press { |
174 | my ($self, $event) = @_; |
214 | my ($self, $event) = @_; |
175 | |
215 | |
… | |
… | |
312 | |
352 | |
313 | --$idx if $keysym == 0xff51; |
353 | --$idx if $keysym == 0xff51; |
314 | ++$idx if $keysym == 0xff53; |
354 | ++$idx if $keysym == 0xff53; |
315 | |
355 | |
316 | $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); |
356 | $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); |
317 | |
357 | |
318 | return 1; |
358 | return 1; |
319 | } elsif ($keysym == 0xff54) { |
359 | } elsif ($keysym == 0xff54) { |
320 | $self->new_tab; |
360 | $self->new_tab; |
321 | |
361 | |
322 | return 1; |
362 | return 1; |