ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/example-filter-input
Revision: 1.1
Committed: Fri Jan 6 01:16:58 2006 UTC (18 years, 4 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3     # same url as used in "selection"
4     my $url =
5     qr{(
6     (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
7     [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often
8     )}x;
9    
10     sub on_add_lines {
11     my ($term, $str) = @_;
12    
13     while ($str =~ $url) {
14     # found a url, first output preceding text
15     $term->scr_add_lines (substr $str, 0, $-[1], "");
16     # then toggle underline
17     $term->rstyle ($term->rstyle ^ urxvt::RS_Uline);
18     # now output the url
19     $term->scr_add_lines (substr $str, 0, $+[1] - $-[1], "");
20     # toggle undelrine again
21     $term->rstyle ($term->rstyle ^ urxvt::RS_Uline);
22     }
23    
24     # output trailing text
25     $term->scr_add_lines ($str);
26    
27     1
28     }
29