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.7 by root, Tue Jan 3 19:42:53 2006 UTC vs.
Revision 1.16 by root, Sun Jan 8 01:32:38 2006 UTC

7 and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection); 7 and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection);
8 8
9 () 9 ()
10} 10}
11 11
12# "find interetsing things"-patterns
13my @mark_patterns = (
14 # urls, just a heuristic
15 qr{(
16 (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
17 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often
18 )}x,
19
20 # common forms of quoting
21 qr{(?:^|\s) [‘`] ([^‘`’']+) [’'] (?:\s|$)}x,
22
23 # shell-like argument quoting
24 qr{\G [\ \t|&;<>()] *(
25 (?:
26 [^\\"'\ \t|&;<>()]+
27 | \\.
28 | " (?: [^\\"]+ | \\. )* "
29 | ' [^']* '
30 )+
31 )}x,
32);
33
34# "correct obvious? crap"-patterns
35my @simplify_patterns = (
36 qr{^"([^\\"'\ \t|&;<>()*?]+)"$}, # "simple" => simple
37 qr{^(.*)[,\-]$}, # strip off trailing , and -
38);
39
12sub on_sel_extend { 40sub on_sel_extend {
13 my ($self) = @_; 41 my ($self) = @_;
14 warn $self->selection; 42
43 my ($row, $col) = $self->selection_mark;
44 my $line = $self->line ($row);
45 my $offset = $line->offset_of ($row, $col);
46 my $text = $line->t;
47
48 for my $regex (@mark_patterns) {
49 while ($text =~ /$regex/g) {
50 if ($-[1] <= $offset and $offset <= $+[1]) {
51 my $ofs = $-[1];
52 my $match = $1;
53
54 for my $regex (@simplify_patterns) {
55 if ($match =~ $regex) {
56 $match = $1;
57 $ofs += $-[1];
58 }
59 }
60
61 $self->selection_beg ($line->coord_of ($ofs));
62 $self->selection_end ($line->coord_of ($ofs + length $match));
63 return 1;
64 }
65 }
66 }
67
15 () 68 ()
16} 69}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines