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 | |
|
|
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. Pressing B<Ctrl-Left> and |
|
|
22 | B<Ctrl-Right> will renumber the current tab by moving it to the left or |
|
|
23 | to the right. |
|
|
24 | |
|
|
25 | The tabbar itself can be configured similarly to a normal terminal, but |
|
|
26 | with a resource class of C<URxvt.tabbed>. In addition, it supports the |
|
|
27 | following 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 | |
|
|
34 | See I<COLOR AND GRAPHICS> in the urxvt(1) manpage for valid |
|
|
35 | indices. |
|
|
36 | |
|
|
37 | =cut |
2 | |
38 | |
3 | sub refresh { |
39 | sub refresh { |
4 | my ($self) = @_; |
40 | my ($self) = @_; |
5 | |
41 | |
6 | my $ncol = $self->ncol; |
42 | my $ncol = $self->ncol; |
… | |
… | |
77 | |
113 | |
78 | # this is an extremely dirty way to force a configurenotify, but who cares |
114 | # this is an extremely dirty way to force a configurenotify, but who cares |
79 | $tab->XMoveResizeWindow ( |
115 | $tab->XMoveResizeWindow ( |
80 | $tab->parent, |
116 | $tab->parent, |
81 | 0, $self->{tabheight} + 1, |
117 | 0, $self->{tabheight} + 1, |
82 | $self->width, |
118 | $self->width, $self->height - $self->{tabheight} |
83 | $self->height - $self->{tabheight} + 2 * $tab->int_bwidth |
|
|
84 | ); |
119 | ); |
85 | $tab->XMoveResizeWindow ( |
120 | $tab->XMoveResizeWindow ( |
86 | $tab->parent, |
121 | $tab->parent, |
87 | 0, $self->{tabheight}, |
122 | 0, $self->{tabheight}, |
88 | $self->width, |
123 | $self->width, $self->height - $self->{tabheight} |
89 | $self->height - $self->{tabheight} + 2 * $tab->int_bwidth |
|
|
90 | ); |
124 | ); |
91 | } |
125 | } |
92 | |
126 | |
93 | sub on_resize_all_windows { |
127 | sub on_resize_all_windows { |
94 | my ($self, $width, $height) = @_; |
128 | my ($self, $width, $height) = @_; |
… | |
… | |
180 | |
214 | |
181 | sub on_key_press { |
215 | sub 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 | |
189 | sub on_key_release { |
224 | sub 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 | |
197 | sub on_button_press { |
233 | sub on_button_press { |
… | |
… | |
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 (\@_) |