ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/selection
Revision: 1.9
Committed: Tue Jan 3 21:08:39 2006 UTC (18 years, 4 months ago) by root
Branch: MAIN
Changes since 1.8: +13 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 sub on_keyboard_command {
4 my ($self, $cmd) = @_;
5
6 $cmd eq "selection:rot13"
7 and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection);
8
9 ()
10 }
11
12 my @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
27 sub on_sel_extend {
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
45 ()
46 }