matcher
authorroot <root>
Tue, 3 Oct 2006 11:32:19 +0000 (11:32 +0000)
committerroot <root>
Tue, 3 Oct 2006 11:32:19 +0000 (11:32 +0000)
Changes
src/perl/mark-urls [deleted file]
src/perl/selection
src/urxvt.pm

diff --git a/Changes b/Changes
index 2a46957fb4b17998c99c5eab704efb1848c46203..d71c93fb7d8765b54aa4a31608350b166195b240 100644 (file)
--- a/Changes
+++ b/Changes
@@ -30,6 +30,8 @@ TODO: (exg) rxvt -fn -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1 U
           basefont, even if explicitly specified (tracked down by tpope).
         - fixed urxvt::strwidth to calculate width in the same way as screen.C.
        - fix a crash caused by passing negative widths to overlay functions.
+       - added 'matcher' extension by tpope, replacing the mark-urls extension.
+        - improve url regex to match anything www.* (tpope).
        - give proper diagnostic when RXVT_SOCKET is too long instead of
           corrupting the stack (patch by exg).
         - urxvtd no longer crashes when the client sends an inaccessible
diff --git a/src/perl/mark-urls b/src/perl/mark-urls
deleted file mode 100644 (file)
index a5f6fd4..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#! perl
-
-# same url as used in "selection"
-my $url =
-   qr{(
-      (?:https?://|ftp://|news://|mailto:|file://)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~#]+
-      [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~]   # exclude some trailing characters (heuristic)
-   )}x;
-
-sub on_start {
-   my ($self) = @_;
-
-   $self->{browser} = $self->x_resource ("urlLauncher") || "x-www-browser";
-
-   ()
-}
-
-sub on_line_update {
-   my ($self, $row) = @_;
-
-   # fetch the line that has changed
-   my $line = $self->line ($row);
-   my $text = $line->t;
-
-   # find all urls (if any)
-   while ($text =~ /$url/g) {
-      my $rend = $line->r;
-
-      # mark all characters as underlined. we _must_ not toggle underline,
-      # as we might get called on an already-marked url.
-      $_ |= urxvt::RS_Uline
-         for @{$rend}[ $-[1] .. $+[1] - 1];
-
-      $line->r ($rend);
-   }
-
-   ()
-}
-
-sub on_button_release {
-    my ($self, $event) = @_;
-
-    my $mask = $self->ModLevel3Mask | $self->ModMetaMask
-             | urxvt::ShiftMask | urxvt::ControlMask;
-
-    if ($event->{button} == 2 && ($event->{state} & $mask) == 0) {
-       my $row = $event->{row};
-       my $col = $event->{col};
-
-       my $line = $self->line ($row);
-       my $text = $line->t;
-    
-       while ($text =~ /$url/g) {
-           if ($-[1] <= $col && $+[1] >= $col) {
-               $self->exec_async ($self->{browser}, $1);
-               return 1;
-           }
-       }
-    }
-
-    ()
-}
-
index 3c5ea547cd38dfb2aae1f5688582aec2f8f086fb..7f0251171438f59bc8b1b43f2f13051ee775bd87 100644 (file)
@@ -46,8 +46,8 @@ my @mark_patterns = (
 
    # urls, just a heuristic
    qr{(
-      (?:https?://|ftp://|news://|mailto:|file://)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~#]+
-      [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~]   # exclude some trailing characters (heuristic)
+      (?:https?://|ftp://|news://|mailto:|file://|\bwww\.)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~#]+
+      [ab-zA-Z0-9\-\@;\/?:&=%\$_+*()~]   # exclude some trailing characters (heuristic)
    )}x,
 
    # shell-like argument quoting, basically always matches
index bd6bde11f6caddd5f8e50b2d12e55a4350baa780..0e5fde5c8f63cf8d0278d86e35156cbdc108db15 100644 (file)
@@ -242,12 +242,30 @@ following four resources (shown with defaults):
 See I<COLOR AND GRAPHICS> in the @@RXVT_NAME@@(1) manpage for valid
 indices.
 
-=item mark-urls
-
-Uses per-line display filtering (C<on_line_update>) to underline urls and
-make them clickable. When middle-clicked, the program specified in the
-resource C<urlLauncher> (default C<x-www-browser>) will be started with
-the URL as first argument.
+=item matcher
+
+Uses per-line display filtering (C<on_line_update>) to underline text
+matching a certain pattern and make it clickable. When clicked with the
+mouse button specified in the C<matcher.button> resource (default 2, or
+middle), the program specified in the C<matcher.launcher> resource
+(default, the C<urlLauncher> resource, C<sensible-browser>) will be started
+with the matched text as first argument.  The default configuration is
+suitable for matching URLs and launching a web browser, like the
+former "mark-urls" extension.
+
+The default pattern to match URLs can be overridden with the
+C<matcher.pattern.0> resource, and additional patterns can be specified
+with numbered patterns, in a manner similar to the "selection" extension.
+The launcher can also be overridden on a per-pattern basis.
+
+Example configuration:
+
+    URxvt.perl-ext:           default,matcher
+    URxvt.urlLauncher:        sensible-browser
+    URxvt.matcher.button:     1
+    URxvt.matcher.pattern.1:  \\bwww\\.[\\w-]\\.[\\w./?&@#-]*[\\w/-]
+    URxvt.matcher.pattern.2:  \\B(/\\S+?):(\\d+)(?=:|$)
+    URxvt.matcher.launcher.2: gvim +$2 $1
 
 =item xim-onthespot