--- rxvt-unicode/src/perl/tabbed 2008/06/15 14:54:44 1.25 +++ rxvt-unicode/src/perl/tabbed 2017/02/26 06:36:46 1.39 @@ -1,5 +1,41 @@ #! perl +#:META:RESOURCE:tabbar-fg:colour:tab bar foreground colour +#:META:RESOURCE:tabbar-bg:colour:tab bar background colour +#:META:RESOURCE:tab-fg:colour:tab foreground colour +#:META:RESOURCE:tab-bg:colour:tab background colour + +=head1 NAME + +tabbed - tabbed interface to urxvt + +=head1 DESCRIPTION + +This transforms the terminal into a tabbar with additional terminals, that +is, it implements what is commonly referred to as "tabbed terminal". The topmost line +displays a "[NEW]" button, which, when clicked, will add a new tab, followed by one +button per tab. + +Clicking a button will activate that tab. Pressing B and +B will switch to the tab left or right of the current one, +while B creates a new tab. Pressing B and +B will renumber the current tab by moving it to the left or +to the right. + +The tabbar itself can be configured similarly to a normal terminal, but +with a resource class of C. In addition, it supports the +following four resources (shown with defaults): + + URxvt.tabbed.tabbar-fg: + URxvt.tabbed.tabbar-bg: + URxvt.tabbed.tab-fg: + URxvt.tabbed.tab-bg: + +See I in the urxvt(1) manpage for valid +indices. + +=cut + sub refresh { my ($self) = @_; @@ -46,8 +82,6 @@ sub new_tab { my ($self, @argv) = @_; - my $offset = $self->fheight; - # save a backlink to us, make sure tabbed is inactive push @urxvt::TERM_INIT, sub { my ($term) = @_; @@ -107,13 +141,13 @@ # pass 1: copy over properties different or nonexisting for my $atom ($tab->XListProperties ($tab->parent)) { my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom); - + # fix up size hints if ($atom == $wm_normal_hints) { my (@hints) = unpack "l!*", $items; - + $hints[$_] += $self->{tabheight} for (4, 6, 16); - + $items = pack "l!*", @hints; } @@ -138,15 +172,15 @@ $cur->XUnmapWindow ($cur->parent) if $cur->mapped; $cur->focus_out; } - + $self->{cur} = $tab; $self->configure; $self->copy_properties; - + $tab->focus_out; # just in case, should be a nop $tab->focus_in if $self->focus; - + $tab->XMapWindow ($tab->parent); delete $tab->{activity}; $self->refresh; @@ -170,10 +204,19 @@ () } +sub on_tt_write { + my ($self, $octets) = @_; + + $self->{cur}->tt_write ($octets); + + 1 +} + sub on_key_press { my ($self, $event) = @_; $self->{cur}->key_press ($event->{state}, $event->{keycode}, $event->{time}); + $self->{cur}->refresh_check; 1 } @@ -182,6 +225,7 @@ my ($self, $event) = @_; $self->{cur}->key_release ($event->{state}, $event->{keycode}, $event->{time}); + $self->{cur}->refresh_check; 1 } @@ -314,7 +358,7 @@ ++$idx if $keysym == 0xff53; $self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]); - + return 1; } elsif ($keysym == 0xff54) { $self->new_tab; @@ -360,7 +404,7 @@ # simply proxies all interesting calls back to the tabbed class. { - for my $hook qw(start destroy key_press property_notify) { + for my $hook (qw(start destroy key_press property_notify)) { eval qq{ sub on_$hook { my \$parent = \$_[0]{term}{parent}