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.1 by root, Fri Jan 20 12:16:28 2006 UTC vs.
Revision 1.6 by root, Fri Jan 20 15:24:24 2006 UTC

1#! perl 1#! perl
2 2
3sub refresh { 3sub refresh {
4 my ($self) = @_; 4 my ($self) = @_;
5 5
6 my $cmd = "\x1b[H\x1b[7m\x1b[K"; 6 my $ncol = $self->ncol;
7
8 my $text = " " x $ncol;
9 my $rend = [(urxvt::DEFAULT_RSTYLE | urxvt::RS_RVid) x $ncol];
10
7 my $txt; 11 my $txt;
8 my @ofs = (0); 12 my $ofs = 0;
13 my @ofs;
9 14
10 for my $tab (@{ $self->{tabs} }) { 15 for my $tab (@{ $self->{tabs} }) {
11 if ($tab == $self->{cur}) {
12 $txt = " [$tab->{name}] "; 16 my $txt = " $tab->{name} ";
13 } else { 17 my $len = length $txt;
14 $txt = " $tab->{name} "; 18
19 substr $text, $ofs, $len + 1, "$txt|";
20 @$rend[$ofs .. $ofs + $len - 1] = (urxvt::OVERLAY_RSTYLE) x $len;
21
22 push @ofs, [
23 $ofs,
24 $ofs + $len,
25 sub {
26 my ($self, $event) = @_;
27 $self->make_current ($tab);
28 },
15 } 29 ];
16 30
17 $cmd .= $txt; 31 $ofs += $len + 1;
18 push @ofs, $ofs[-1] + length $txt;
19 } 32 }
20 33
21 $self->{tabofs} = \@ofs; 34 $self->{tabofs} = \@ofs;
22 35
23 $self->cmd_parse ($self->locale_encode ($cmd)); 36 $self->ROW_t (0, $text);
37 $self->ROW_r (0, $rend);
24} 38}
25 39
26sub new_tab { 40sub new_tab {
27 my ($self) = @_; 41 my ($self) = @_;
28 42
49} 63}
50 64
51sub configure { 65sub configure {
52 my ($self) = @_; 66 my ($self) = @_;
53 67
54 my $tabheight = $self->int_bwidth + $self->fheight + $self->lineSpace; 68 my $tab = $self->{cur};
55 69
56 $self->{cur}->XMoveResizeWindow ( 70 $tab->XMoveResizeWindow (
57 $self->{cur}->parent, 71 $tab->parent,
58 0, $tabheight, 72 0, $self->{tabheight},
59 $self->width, $self->height - $tabheight 73 $self->width, $self->height - $self->{tabheight}
60 ); 74 );
75
76 my $wm_normal_hints = $self->XInternAtom ("WM_NORMAL_HINTS");
77
78 for my $atom ($tab->XListProperties ($tab->parent)) {
79 my ($type, $format, $items) = $self->XGetWindowProperty ($tab->parent, $atom);
80
81 if ($atom == $wm_normal_hints) {
82 my (@hints) = unpack "l!*", $items;
83
84 $hints[$_] += $self->{tabheight} for (4, 6, 16);
85
86 $items = pack "l!*", @hints;
87 }
88 $self->XChangeWindowProperty ($self->parent, $atom, $type, $format, $items);
89 }
90
91 $self->refresh;
61} 92}
62 93
63sub make_current { 94sub make_current {
64 my ($self, $tab) = @_; 95 my ($self, $tab) = @_;
65 96
84} 115}
85 116
86sub on_button_release { 117sub on_button_release {
87 my ($self, $event) = @_; 118 my ($self, $event) = @_;
88 119
89 my $ofs = $self->{tabofs};
90
91 if ($event->{row} == 0) { 120 if ($event->{row} == 0) {
92 for my $i (0 .. @$ofs - 2) { 121 for my $button (@{ $self->{tabofs} }) {
122 $button->[2]->($self, $event)
93 if ($event->{col} >= $ofs->[$i] 123 if $event->{col} >= $button->[0]
94 && $event->{col} < $ofs->[$i+1]) { 124 && $event->{col} < $button->[1];
95 $self->make_current ($self->{tabs}[$i]);
96 }
97 } 125 }
98 } 126 }
99 127
100 1 128 1
101} 129}
123 () 151 ()
124} 152}
125 153
126sub on_start { 154sub on_start {
127 my ($self) = @_; 155 my ($self) = @_;
156
157 $self->{tabheight} = $self->int_bwidth + $self->fheight + $self->lineSpace;
128 158
129 $self->cmd_parse ("\x1b[?25l\x1b[?7l"); 159 $self->cmd_parse ("\x1b[?25l\x1b[?7l");
130 $self->new_tab; 160 $self->new_tab;
131 $self->new_tab; 161 $self->new_tab;
132 $self->new_tab; 162 $self->new_tab;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines