ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/selection
(Generate patch)

Comparing rxvt-unicode/src/perl/selection (file contents):
Revision 1.52 by root, Sat Dec 26 10:50:46 2009 UTC vs.
Revision 1.53 by sf-exg, Sun Mar 13 17:07:36 2011 UTC

17 push @{ $self->{patterns} }, qr{\G [\Q$res\E[:space:]]* ([^\Q$res\E[:space:]]+) }x; 17 push @{ $self->{patterns} }, qr{\G [\Q$res\E[:space:]]* ([^\Q$res\E[:space:]]+) }x;
18 } 18 }
19 19
20 for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) { 20 for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) {
21 $res = $self->locale_decode ($res); 21 $res = $self->locale_decode ($res);
22 utf8::encode $res;
23 push @{ $self->{patterns} }, qr/$res/; 22 push @{ $self->{patterns} }, qr/$res/;
24 } 23 }
25 24
26 $self->{enabled} = 1; 25 $self->{enabled} = 1;
27 26
91 - $line->offset_of ($self->selection_beg); 90 - $line->offset_of ($self->selection_beg);
92 91
93 my @matches; 92 my @matches;
94 93
95 if ($markofs < $line->l) { 94 if ($markofs < $line->l) {
96 # convert markofs from character to UTF-8 offset space
97 {
98 my $prefix = substr $text, 0, $markofs;
99 utf8::encode $prefix;
100 $markofs = length $prefix;
101 }
102
103 # not doing matches in unicode mode helps speed
104 # enourmously here. working in utf-8 should be
105 # equivalent due to the magic of utf-8 encoding.
106 utf8::encode $text;
107 study $text; # _really_ helps, too :) 95 study $text; # _really_ helps, too :)
108 96
109 for my $regex (@mark_patterns, @{ $self->{patterns} }) { 97 for my $regex (@mark_patterns, @{ $self->{patterns} }) {
110 while ($text =~ /$regex/g) { 98 while ($text =~ /$regex/g) {
111 if ($-[1] <= $markofs and $markofs <= $+[1]) { 99 if ($-[1] <= $markofs and $markofs <= $+[1]) {
131 for (sort { $a->[1] <=> $b->[1] or $b->[0] <=> $a->[0] } @matches) { 119 for (sort { $a->[1] <=> $b->[1] or $b->[0] <=> $a->[0] } @matches) {
132 my ($ofs, $len) = @$_; 120 my ($ofs, $len) = @$_;
133 121
134 next if $len <= $curlen; 122 next if $len <= $curlen;
135 123
136 # convert back from UTF-8 offset space to character space
137 {
138 my $length = substr "$text ", $ofs, $len;
139 utf8::decode $length;
140 $len = length $length;
141 }
142 {
143 my $prefix = substr $text, 0, $ofs;
144 utf8::decode $prefix;
145 $ofs = length $prefix;
146 }
147
148 $self->selection_beg ($line->coord_of ($ofs)); 124 $self->selection_beg ($line->coord_of ($ofs));
149 $self->selection_end ($line->coord_of ($ofs + $len)); 125 $self->selection_end ($line->coord_of ($ofs + $len));
150 return 1; 126 return 1;
151 } 127 }
152 128

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines