*** empty log message ***
authorroot <root>
Thu, 5 Jan 2006 01:04:10 +0000 (01:04 +0000)
committerroot <root>
Thu, 5 Jan 2006 01:04:10 +0000 (01:04 +0000)
src/perl/mark-urls [new file with mode: 0644]

diff --git a/src/perl/mark-urls b/src/perl/mark-urls
new file mode 100644 (file)
index 0000000..6bd16c2
--- /dev/null
@@ -0,0 +1,29 @@
+#! perl
+
+# same url as used in "selection"
+my $url =
+   qr{(
+      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+
+      [^.]   # do not include a trailing dot, its wrong too often
+   )}x;
+
+sub on_add_lines {
+   my ($term, $str) = @_;
+
+   while ($str =~ $url) {
+      # found a url, first output preceding text
+      $term->scr_add_lines (substr $str, 0, $-[1], "");
+      # then toggle underline
+      $term->rstyle ($term->rstyle ^ urxvt::RS_Uline);
+      # now output the url
+      $term->scr_add_lines (substr $str, 0, $+[1] - $-[1], "");
+      # toggle undelrine again
+      $term->rstyle ($term->rstyle ^ urxvt::RS_Uline);
+   }
+
+   # output trailing text
+   $term->scr_add_lines ($str);
+
+   1
+}
+