--- rxvt-unicode/src/urxvt.pm 2006/01/12 05:37:34 1.87
+++ rxvt-unicode/src/urxvt.pm 2006/01/17 16:53:47 1.97
@@ -50,7 +50,25 @@
A double-click usually selects the word under the cursor, further clicks
will enlarge the selection.
-It also offers the following bindable keyboard command:
+The selection works by trying to match a number of regexes and displaying
+them in increasing order of length. You can add your own regexes by
+specifying resources of the form:
+
+ URxvt.selection.pattern-0: perl-regex
+ URxvt.selection.pattern-1: perl-regex
+ ...
+
+The index number (0, 1...) must not have any holes, and each regex must
+contain at least one pair of capturing parentheses, which will be used for
+the match. For example, the followign adds a regex that matches everything
+between two vertical bars:
+
+ URxvt.selection.pattern-0: \\|([^|]+)\\|
+
+You can look at the source of the selection extension to see more
+interesting uses, such as parsing a line from beginning to end.
+
+This extension also offers following bindable keyboard commands:
=over 4
@@ -88,9 +106,40 @@
additionally stores the first match in the current line into the primary
selection.
-=item digital-clock
+=item selection-autotransform
-Displays a digital clock using the built-in overlay.
+This selection allows you to do automatic transforms on a selection
+whenever a selection is made.
+
+It works by specifying perl snippets (most useful is a single C
+operator) that modify C<$_> as resources:
+
+ URxvt.selection-autotransform.0: transform
+ URxvt.selection-autotransform.1: transform
+ ...
+
+For example, the following will transform selections of the form
+C, often seen in compiler messages, into C:
+
+ URxvt.selection-autotransform.0: s/^([^:[:space:]]+):(\\d+):?$/vi +$2 \\Q$1\\E\\x0d/
+
+And this example matches the same,but replaces it with vi-commands you can
+paste directly into your (vi :) editor:
+
+ URxvt.selection-autotransform.0: s/^([^:[:space:]]+(\\d+):?$/\\x1b:e \\Q$1\\E\\x0d:$2\\x0d/
+
+Of course, this can be modified to suit your needs and your editor :)
+
+To expand the example above to typical perl error messages ("XXX at
+FILENAME line YYY."), you need a slightly more elaborate solution:
+
+ URxvt.selection.pattern-0: ( at .*? line \\d+\\.)
+ URxvt.selection-autotransform.0: s/^ at (.*?) line (\\d+)\\.$/\x1b:e \\Q$1\E\\x0d:$2\\x0d/
+
+The first line tells the selection code to treat the unchanging part of
+every error message as a selection pattern, and the second line transforms
+the message into vi commands to load the file.
=item mark-urls
@@ -105,12 +154,33 @@
by replacing all line-drawing characters (U+2500 .. U+259F) by a
similar-looking ascii character.
+=item digital-clock
+
+Displays a digital clock using the built-in overlay.
+
=item example-refresh-hooks
Displays a very simple digital clock in the upper right corner of the
window. Illustrates overwriting the refresh callbacks to create your own
overlays or changes.
+=item selection-pastebin
+
+Uploads the selection as textfile to a remote site.
+
+ URxvt.keysym.C-M-e: perl:selection-pastebin:remote-pastebin
+
+To set the command to upload the file set this resource:
+
+ URxvt.selection-pastebin-cmd: rsync -apP % ruth:/var/www/www.ta-sa.org/files/txt/.
+
+The % is the placeholder for the textfile. The name of the textfile is the hex encoded
+md5 sum of the selection.
+After an successful upload the selection will be replaced by the following url
+(the % is the placeholder for the filename):
+
+ URxvt.selection-pastebin-url: http://www.ta-sa.org/files/txt/%
+
=back
=head1 API DOCUMENTATION
@@ -320,6 +390,12 @@
C action bound to it (see description of the B
resource in the @@RXVT_NAME@@(1) manpage).
+=item on_x_event $term, $event
+
+Called on every X event received on the vt window (and possibly other
+windows). Should only be used as a last resort. Most event structure
+members are not passed.
+
=item on_focus_in $term
Called whenever the window gets the keyboard focus, before rxvt-unicode
@@ -424,12 +500,6 @@
Messages have a size limit of 1023 bytes currently.
-=item $is_safe = urxvt::safe
-
-Returns true when it is safe to do potentially unsafe things, such as
-evaluating perl code specified by the user. This is true when urxvt was
-started setuid or setgid.
-
=item $time = urxvt::NOW
Returns the "current time" (as per the event loop).
@@ -440,6 +510,22 @@
Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask,
Button4Mask, Button5Mask, AnyModifier
+=item urxvt::NoEventMask, KeyPressMask, KeyReleaseMask,
+ButtonPressMask, ButtonReleaseMask, EnterWindowMask, LeaveWindowMask,
+PointerMotionMask, PointerMotionHintMask, Button1MotionMask, Button2MotionMask,
+Button3MotionMask, Button4MotionMask, Button5MotionMask, ButtonMotionMask,
+KeymapStateMask, ExposureMask, VisibilityChangeMask, StructureNotifyMask,
+ResizeRedirectMask, SubstructureNotifyMask, SubstructureRedirectMask,
+FocusChangeMask, PropertyChangeMask, ColormapChangeMask, OwnerGrabButtonMask
+
+=item urxvt::KeyPress, KeyRelease, ButtonPress, ButtonRelease, MotionNotify,
+EnterNotify, LeaveNotify, FocusIn, FocusOut, KeymapNotify, Expose,
+GraphicsExpose, NoExpose, VisibilityNotify, CreateNotify, DestroyNotify,
+UnmapNotify, MapNotify, MapRequest, ReparentNotify, ConfigureNotify,
+ConfigureRequest, GravityNotify, ResizeRequest, CirculateNotify,
+CirculateRequest, PropertyNotify, SelectionClear, SelectionRequest,
+SelectionNotify, ColormapNotify, ClientMessage, MappingNotify
+
Various constants for use in X calls and event processing.
=back
@@ -516,7 +602,6 @@
$ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin";
}
-my @hook_count;
my $verbosity = $ENV{URXVT_PERL_VERBOSITY};
sub verbose {
@@ -539,7 +624,7 @@
open my $fh, "<:raw", $path
or die "$path: $!";
- my $source = untaint
+ my $source =
"package $pkg; use strict; use utf8;\n"
. "use base urxvt::term::extension::;\n"
. "#line 1 \"$path\"\n{\n"
@@ -614,13 +699,6 @@
}
if ($htype == 1) { # DESTROY
- if (my $hook = delete $TERM->{_hook}) {
- for my $htype (0..$#$hook) {
- $hook_count[$htype] -= scalar keys %{ $hook->[$htype] || {} }
- or set_should_invoke $htype, 0;
- }
- }
-
# clear package objects
%$_ = () for values %{ $TERM->{_pkg} };
@@ -656,10 +734,8 @@
defined $htype
or Carp::croak "unsupported hook type '$name'";
- unless (exists $self->{term}{_hook}[$htype]{$pkg}) {
- $hook_count[$htype]++
- or urxvt::set_should_invoke $htype, 1;
- }
+ $self->set_should_invoke ($htype, +1)
+ unless exists $self->{term}{_hook}[$htype]{$pkg};
$self->{term}{_hook}[$htype]{$pkg} = $cb;
}
@@ -674,10 +750,8 @@
defined $htype
or Carp::croak "unsupported hook type '$name'";
- if (delete $self->{term}{_hook}[$htype]{$pkg}) {
- --$hook_count[$htype]
- or urxvt::set_should_invoke $htype, 0;
- }
+ $self->set_should_invoke ($htype, -1)
+ if delete $self->{term}{_hook}[$htype]{$pkg};
}
}
@@ -1092,6 +1166,13 @@
Return the window id of the terminal window.
+=item $term->vt_emask_add ($x_event_mask)
+
+Adds the specified events to the vt event mask. Useful e.g. when you want
+to receive pointer events all the times:
+
+ $term->vt_emask_add (urxvt::PointerMotionMask);
+
=item $window_width = $term->width
=item $window_height = $term->height
@@ -1114,7 +1195,7 @@
=item $nrow_plus_saveLines = $term->total_rows
-=item $lines_in_scrollback = $term->nsaved
+=item $topmost_scrollback_row = $term->top_row
Return various integers describing terminal characteristics.
@@ -1152,8 +1233,8 @@
=item $view_start = $term->view_start ([$newvalue])
-Returns the negative row number of the topmost line. Minimum value is
-C<0>, which displays the normal terminal contents. Larger values scroll
+Returns the row number of the topmost displayed line. Maximum value is
+C<0>, which displays the normal terminal contents. Lower values scroll
this many lines into the scrollback buffer.
=item $term->want_refresh