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.6 by root, Fri Jan 20 15:24:24 2006 UTC vs.
Revision 1.7 by root, Fri Jan 20 15:40:39 2006 UTC

6 my $ncol = $self->ncol; 6 my $ncol = $self->ncol;
7 7
8 my $text = " " x $ncol; 8 my $text = " " x $ncol;
9 my $rend = [(urxvt::DEFAULT_RSTYLE | urxvt::RS_RVid) x $ncol]; 9 my $rend = [(urxvt::DEFAULT_RSTYLE | urxvt::RS_RVid) x $ncol];
10 10
11 my $txt;
12 my $ofs = 0;
13 my @ofs; 11 my @ofs;
14 12
13 substr $text, 0, 7, "[NEW] |";
14 @$rend[0 .. 5] = (urxvt::OVERLAY_RSTYLE) x 6;
15 push @ofs, [0, 6, sub { $_[0]->new_tab }];
16
17 my $ofs = 7;
18 my $idx = 0;
19
15 for my $tab (@{ $self->{tabs} }) { 20 for my $tab (@{ $self->{tabs} }) {
21 $idx++;
22
16 my $txt = " $tab->{name} "; 23 my $txt = " $idx ";
17 my $len = length $txt; 24 my $len = length $txt;
18 25
19 substr $text, $ofs, $len + 1, "$txt|"; 26 substr $text, $ofs, $len + 1, "$txt|";
20 @$rend[$ofs .. $ofs + $len - 1] = (urxvt::OVERLAY_RSTYLE) x $len; 27 @$rend[$ofs .. $ofs + $len - 1] = (urxvt::OVERLAY_RSTYLE) x $len
28 if $tab == $self->{cur};
21 29
22 push @ofs, [ 30 push @ofs, [ $ofs, $ofs + $len, sub { $_[0]->make_current ($tab) } ];
23 $ofs,
24 $ofs + $len,
25 sub {
26 my ($self, $event) = @_;
27 $self->make_current ($tab);
28 },
29 ];
30 31
31 $ofs += $len + 1; 32 $ofs += $len + 1;
32 } 33 }
33 34
34 $self->{tabofs} = \@ofs; 35 $self->{tabofs} = \@ofs;
35 36
36 $self->ROW_t (0, $text); 37 $self->ROW_t (0, $text, 0, 0, $ncol);
37 $self->ROW_r (0, $rend); 38 $self->ROW_r (0, $rend, 0, 0, $ncol);
39
40 $self->want_refresh;
38} 41}
39 42
40sub new_tab { 43sub new_tab {
41 my ($self) = @_; 44 my ($self) = @_;
42 45
93 96
94sub make_current { 97sub make_current {
95 my ($self, $tab) = @_; 98 my ($self, $tab) = @_;
96 99
97 if (my $cur = $self->{cur}) { 100 if (my $cur = $self->{cur}) {
98 $cur->XUnmapWindow ($cur->parent) 101 $cur->XUnmapWindow ($cur->parent) if $cur->mapped;
99 if $cur->mapped; 102 $cur->focus_out;
100 } 103 }
101 104
102 $self->{cur} = $tab; 105 $self->{cur} = $tab;
103 106
104 $self->configure; 107 $self->configure;
105 108 $tab->focus_in;
106 $tab->XMapWindow ($tab->parent); 109 $tab->XMapWindow ($tab->parent);
107
108 $self->refresh; 110 $self->refresh;
109 111
110 () 112 ()
111} 113}
112 114
154sub on_start { 156sub on_start {
155 my ($self) = @_; 157 my ($self) = @_;
156 158
157 $self->{tabheight} = $self->int_bwidth + $self->fheight + $self->lineSpace; 159 $self->{tabheight} = $self->int_bwidth + $self->fheight + $self->lineSpace;
158 160
159 $self->cmd_parse ("\x1b[?25l\x1b[?7l");
160 $self->new_tab;
161 $self->new_tab;
162 $self->new_tab; 161 $self->new_tab;
163 162
164 () 163 ()
165} 164}
166 165
183sub tab_start { 182sub tab_start {
184 my ($self, $tab) = @_; 183 my ($self, $tab) = @_;
185 184
186 push @{ $self->{tabs} }, $tab; 185 push @{ $self->{tabs} }, $tab;
187 186
188 $tab->{name} ||= scalar @{ $self->{tabs} }; 187# $tab->{name} ||= scalar @{ $self->{tabs} };
189 $self->make_current ($tab); 188 $self->make_current ($tab);
190 189
191 () 190 ()
192} 191}
193 192
198 197
199 if (@{ $self->{tabs} }) { 198 if (@{ $self->{tabs} }) {
200 if ($self->{cur} == $tab) { 199 if ($self->{cur} == $tab) {
201 delete $self->{cur}; 200 delete $self->{cur};
202 $self->make_current ($self->{tabs}[-1]); 201 $self->make_current ($self->{tabs}[-1]);
202 } else {
203 $self->refresh;
203 } 204 }
204 } else { 205 } else {
205 # delay destruction a tiny bit 206 # delay destruction a tiny bit
206 $self->{destroy} = urxvt::iw->new->start->cb (sub { $self->destroy }); 207 $self->{destroy} = urxvt::iw->new->start->cb (sub { $self->destroy });
207 } 208 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines