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.6 by root, Tue Jan 3 19:12:53 2006 UTC vs.
Revision 1.9 by root, Tue Jan 3 21:08:39 2006 UTC

1#! perl 1#! perl
2 2
3sub on_keyboard_command { 3sub on_keyboard_command {
4 my ($term, $cmd) = @_; 4 my ($self, $cmd) = @_;
5 5
6 $cmd eq "selection:rot13" 6 $cmd eq "selection:rot13"
7 and $term->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $term->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
12my @patterns = (
13 # urls
14 qr{ ([a-z0-9.+\-]+://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+) }x,
15
16 # shell-like argument quoting
17 qr{\G\s*(
18 (?:
19 [^"'\\ \t]+
20 | \\.
21 | " ([^\\"]+ | \\. )* "
22 | ' [^']* '
23 )+
24 )}xs,
25);
26
12sub on_sel_extend { 27sub on_sel_extend {
13 warn "hiya\n";#d# 28 my ($self) = @_;
29
30 my ($row, $col) = $self->selection_mark;
31 my $line = $self->line ($row);
32 my $offset = $line->offset_of ($row, $col);
33 my $text = $line->t;
34
35 for my $regex (@patterns) {
36 while ($text =~ /$regex/g) {
37 if ($-[1] <= $offset and $offset <= $+[1]) {
38 $self->selection_beg ($line->coord_of ($-[1]));
39 $self->selection_end ($line->coord_of ($+[1]));
40 return 1;
41 }
42 }
43 }
44
14 () 45 ()
15} 46}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines