--- rxvt-unicode/src/urxvt.pm 2006/07/06 23:48:11 1.143 +++ rxvt-unicode/src/urxvt.pm 2007/11/16 10:06:40 1.160 @@ -19,7 +19,7 @@ =head1 DESCRIPTION -Everytime a terminal object gets created, extension scripts specified via +Every time a terminal object gets created, extension scripts specified via the C resource are loaded and associated with it. Scripts are compiled in a 'use strict' and 'use utf8' environment, and @@ -28,6 +28,9 @@ Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where scripts will be shared (but not enabled) for all terminals. +You can disable the embedded perl interpreter by setting both "perl-ext" +and "perl-ext-common" resources to the empty string. + =head1 PREPACKAGED EXTENSIONS This section describes the extensions delivered with this release. You can @@ -39,7 +42,7 @@ Or by adding them to the resource for extensions loaded by default: - URxvt.perl-ext-common: default,automove-background,selection-autotransform + URxvt.perl-ext-common: default,selection-autotransform =over 4 @@ -64,7 +67,7 @@ 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 +the match. For example, the following adds a regex that matches everything between two vertical bars: URxvt.selection.pattern-0: \\|([^|]+)\\| @@ -100,7 +103,7 @@ onto C<@{ $term->{option_popup_hook} }>, which gets called whenever the popup is being displayed. -It's sole argument is the popup menu, which can be modified. It should +Its sole argument is the popup menu, which can be modified. It should either return nothing or a string, the initial boolean value and a code reference. The string will be used as button text and the code reference will be called when the toggle changes, with the new boolean value as @@ -123,8 +126,8 @@ onto C<@{ $term->{selection_popup_hook} }>, which gets called whenever the popup is being displayed. -It's sole argument is the popup menu, which can be modified. The selection -is in C<$_>, which can be used to decide wether to add something or not. +Its sole argument is the popup menu, which can be modified. The selection +is in C<$_>, which can be used to decide whether to add something or not. It should either return nothing or a string and a code reference. The string will be used as button text and the code reference will be called when the button gets activated and should transform C<$_>. @@ -134,7 +137,7 @@ Cs: push @{ $self->{term}{selection_popup_hook} }, sub { - /a/ ? ("a to be" => sub { s/a/b/g } + /a/ ? ("a to b" => sub { s/a/b/g } : () }; @@ -151,7 +154,7 @@ bottom. C leaves search mode and returns to the point where search was started, while C or C stay at the current position and additionally stores the first match in the current line into the primary -selection. +selection if the C modifier is active. The regex defaults to "(?i)", resulting in a case-insensitive search. To get a case-sensitive search you can delete this prefix using C @@ -222,7 +225,7 @@ =item tabbed This transforms the terminal into a tabbar with additional terminals, that -is, it implements what is commonly refered to as "tabbed terminal". The topmost line +is, it implements what is commonly referred to as "tabbed terminal". The topmost line displays a "[NEW]" button, which, when clicked, will add a new tab, followed by one button per tab. @@ -242,18 +245,40 @@ See I in the @@RXVT_NAME@@(1) manpage for valid indices. -=item mark-urls +=item matcher -Uses per-line display filtering (C) to underline urls and -make them clickable. When middle-clicked, the program specified in the -resource C (default C) will be started with -the URL as first argument. +Uses per-line display filtering (C) to underline text +matching a certain pattern and make it clickable. When clicked with the +mouse button specified in the C resource (default 2, or +middle), the program specified in the C resource +(default, the C resource, C) 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 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. + +It is possible to activate the most recently seen match from the keyboard. +Simply bind a keysym to "perl:matcher" as seen in the example below. + +Example configuration: + + URxvt.perl-ext: default,matcher + URxvt.urlLauncher: sensible-browser + URxvt.keysym.C-Delete: perl:matcher + 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 This (experimental) perl extension implements OnTheSpot editing. It does not work perfectly, and some input methods don't seem to work well with -OnTheSpot editing in general, but it seems to work at leats for SCIM and +OnTheSpot editing in general, but it seems to work at least for SCIM and kinput2. You enable it by specifying this extension and a preedit style of @@ -271,24 +296,15 @@ Initially, the window will not be shown when using this extension. -This is useful if you need a single terminal thats not using any desktop +This is useful if you need a single terminal that is not using any desktop space most of the time but is quickly available at the press of a key. -The accelerator key is grabbed regardless of any modifers, so this +The accelerator key is grabbed regardless of any modifiers, so this extension will actually grab a physical key just for this function. If you want a quake-like animation, tell your window manager to do so (fvwm can do it). -=item automove-background - -This is basically a very small extension that dynamically changes the -background pixmap offset to the window position, in effect creating the -same effect as pseudo transparency with a custom pixmap. No scaling is -supported in this mode. Exmaple: - - @@RXVT_NAME@@ -pixmap background.xpm -pe automove-background - =item block-graphics-to-ascii A not very useful example of filtering all text output to the terminal @@ -302,7 +318,7 @@ =item remote-clipboard Somewhat of a misnomer, this extension adds two menu entries to the -selection popup that allows one ti run external commands to store the +selection popup that allows one to run external commands to store the selection somewhere and fetch it again. We use it to implement a "distributed selection mechanism", which just @@ -348,6 +364,11 @@ URxvt.selection-pastebin.url: http://www.ta-sa.org/files/txt/% +I xrdb uses the C preprocessor, which might interpret +the double C characters as comment start. Use C<\057\057> instead, +which works regardless of wether xrdb is used to parse the resource file +or not. + =item example-refresh-hooks Displays a very simple digital clock in the upper right corner of the @@ -397,11 +418,12 @@ =head2 Extension Objects Every perl extension is a perl class. A separate perl object is created -for each terminal and each extension and passed as the first parameter to -hooks. So extensions can use their C<$self> object without having to think -about other extensions, with the exception of methods and members that -begin with an underscore character C<_>: these are reserved for internal -use. +for each terminal, and each terminal has its own set of extenion objects, +which are passed as the first parameter to hooks. So extensions can use +their C<$self> object without having to think about clashes with other +extensions or other terminals, with the exception of methods and members +that begin with an underscore character C<_>: these are reserved for +internal use. Although it isn't a C object, you can call all methods of the C class on this object. @@ -432,7 +454,7 @@ The following subroutines can be declared in extension files, and will be called whenever the relevant event happens. -The first argument passed to them is an extension oject as described in +The first argument passed to them is an extension object as described in the in the C section. B of these hooks must return a boolean value. If any of the called @@ -455,7 +477,7 @@ =item on_start $term Called at the very end of initialisation of a new terminal, just before -trying to map (display) the toplevel and returning to the mainloop. +trying to map (display) the toplevel and returning to the main loop. =item on_destroy $term @@ -492,13 +514,13 @@ requested from the server. The selection text can be queried and changed by calling C<< $term->selection >>. -Returning a true value aborts selection grabbing. It will still be hilighted. +Returning a true value aborts selection grabbing. It will still be highlighted. =item on_sel_extend $term Called whenever the user tries to extend the selection (e.g. with a double click) and is either supposed to return false (normal operation), or -should extend the selection itelf and return true to suppress the built-in +should extend the selection itself and return true to suppress the built-in processing. This can happen multiple times, as long as the callback returns true, it will be called on every further click by the user and is supposed to enlarge the selection more and more, if possible. @@ -507,7 +529,7 @@ =item on_view_change $term, $offset -Called whenever the view offset changes, i..e the user or program +Called whenever the view offset changes, i.e. the user or program scrolls. Offset C<0> means display the normal terminal, positive values show this many lines of scrollback. @@ -541,7 +563,7 @@ future. Be careful not ever to trust (in a security sense) the data you receive, -as its source can not easily be controleld (e-mail content, messages from +as its source can not easily be controlled (e-mail content, messages from other users on the same system etc.). =item on_add_lines $term, $string @@ -584,7 +606,7 @@ =item on_user_command $term, $string -Called whenever the a user-configured event is being activated (e.g. via +Called whenever a user-configured event is being activated (e.g. via a C action bound to a key, see description of the B resource in the @@RXVT_NAME@@(1) manpage). @@ -593,7 +615,7 @@ =item on_resize_all_windows $tern, $new_width, $new_height -Called just after the new window size has been calculcated, but before +Called just after the new window size has been calculated, but before windows are actually being resized or hints are being set. If this hook returns TRUE, setting of the window hints is being skipped. @@ -614,7 +636,7 @@ =item on_focus_out $term -Called wheneever the window loses keyboard focus, before rxvt-unicode does +Called whenever the window loses keyboard focus, before rxvt-unicode does focus out processing. =item on_configure_notify $term, $event @@ -707,12 +729,12 @@ =item @urxvt::TERM_INIT -All coderefs in this array will be called as methods of the next newly +All code references in this array will be called as methods of the next newly created C object (during the C phase). The array -gets cleared before the codereferences that were in it are being executed, -so coderefs can push themselves onto it again if they so desire. +gets cleared before the code references that were in it are being executed, +so references can push themselves onto it again if they so desire. -This complements to the perl-eval commandline option, but gets executed +This complements to the perl-eval command line option, but gets executed first. =item @urxvt::TERM_EXT @@ -747,7 +769,7 @@ =item @terms = urxvt::termlist Returns all urxvt::term objects that exist in this process, regardless of -wether they are started, being destroyed etc., so be careful. Only term +whether they are started, being destroyed etc., so be careful. Only term objects that have perl extensions attached will be returned (because there is no urxvt::term objet associated with others). @@ -895,7 +917,7 @@ if ($htype == 0) { # INIT my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); - + my %ext_arg; { @@ -968,6 +990,31 @@ SET_BGCOLOR (SET_FGCOLOR ($_[0], $_[1]), $_[2]) } +sub rend2mask { + no strict 'refs'; + my ($str, $mask) = (@_, 0); + my %color = ( fg => undef, bg => undef ); + my @failed; + for my $spec ( split /\s+/, $str ) { + if ( $spec =~ /^([fb]g)[_:-]?(\d+)/i ) { + $color{lc($1)} = $2; + } else { + my $neg = $spec =~ s/^[-^]//; + unless ( exists &{"RS_$spec"} ) { + push @failed, $spec; + next; + } + my $cur = &{"RS_$spec"}; + if ( $neg ) { + $mask &= ~$cur; + } else { + $mask |= $cur; + } + } + } + ($mask, @color{qw(fg bg)}, \@failed) +} + # urxvt::term::extension package urxvt::term::extension; @@ -1088,19 +1135,23 @@ } sub condvar { - bless \my $flag, urxvt::anyevent::condvar:: + bless \my $flag, urxvt::anyevent:: } -sub urxvt::anyevent::condvar::broadcast { +sub broadcast { ${$_[0]}++; } -sub urxvt::anyevent::condvar::wait { +sub wait { unless (${$_[0]}) { Carp::croak "AnyEvent->condvar blocking wait unsupported in urxvt, use a non-blocking API"; } } +sub one_event { + Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a non-blocking API"; +} + package urxvt::term; =head2 The C Class @@ -1195,7 +1246,7 @@ optionally change it. All option values are stored by name in the hash C<%urxvt::OPTION>. Options not enabled in this binary are not in the hash. -Here is a a likely non-exhaustive list of option names, please see the +Here is a likely non-exhaustive list of option names, please see the source file F to see the actual list: borderLess console cursorBlink cursorUnderline hold iconic insecure @@ -1222,7 +1273,7 @@ Please note that resource strings will currently only be freed when the terminal is destroyed, so changing options frequently will eat memory. -Here is a a likely non-exhaustive list of resource names, not all of which +Here is a likely non-exhaustive list of resource names, not all of which are supported in every build, please see the source file F to see the actual list: @@ -1544,7 +1595,7 @@ =item $cursor_is_hidden = $term->hidden_cursor -Returns wether the cursor is currently hidden or not. +Returns whether the cursor is currently hidden or not. =item $view_start = $term->view_start ([$newvalue]) @@ -1731,7 +1782,7 @@ =item $string = $term->special_decode $text -Converts rxvt-unicodes text reprsentation into a perl string. See +Converts rxvt-unicodes text representation into a perl string. See C<< $term->ROW_t >> for details. =item $success = $term->grab_button ($button, $modifiermask[, $window = $term->vt]) @@ -1744,7 +1795,7 @@ =item $success = $term->grab ($eventtime[, $sync]) Calls XGrabPointer and XGrabKeyboard in asynchronous (default) or -synchronous (C<$sync> is true). Also remembers the grab timestampe. +synchronous (C<$sync> is true). Also remembers the grab timestamp. =item $term->allow_events_async @@ -1928,11 +1979,6 @@ package urxvt::watcher; -@urxvt::timer::ISA = __PACKAGE__; -@urxvt::iow::ISA = __PACKAGE__; -@urxvt::pw::ISA = __PACKAGE__; -@urxvt::iw::ISA = __PACKAGE__; - =head2 The C Class This class implements timer watchers/events. Time is represented as a @@ -1945,7 +1991,7 @@ ->cb (sub { $term->{overlay}->set (0, 0, sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); - }); + }); =over 4 @@ -1998,7 +2044,7 @@ $term->{iow} = urxvt::iow ->new ->fd (fileno $term->{socket}) - ->events (urxvt::EVENT_READ) + ->events (urxvt::EV_READ) ->start ->cb (sub { my ($iow, $revents) = @_; @@ -2021,13 +2067,13 @@ =item $iow = $iow->fd ($fd) -Set the filedescriptor (not handle) to watch. +Set the file descriptor (not handle) to watch. =item $iow = $iow->events ($eventmask) Set the event mask to watch. The only allowed values are -C and C, which might be ORed -together, or C. +C and C, which might be ORed +together, or C. =item $iow = $iow->start @@ -2035,7 +2081,7 @@ =item $iow = $iow->stop -Stop watching for events on the given filehandle. +Stop watching for events on the given file handle. =back @@ -2078,7 +2124,7 @@ ->cb (sub { my ($pw, $exit_status) = @_; ... - }); + }); =over 4 @@ -2092,7 +2138,7 @@ =item $pw = $timer->start ($pid) -Tells the wqtcher to start watching for process C<$pid>. +Tells the watcher to start watching for process C<$pid>. =item $pw = $pw->stop @@ -2115,7 +2161,7 @@ =item >=10 - all called hooks -=item >=11 - hook reutrn values +=item >=11 - hook return values =back @@ -2127,3 +2173,5 @@ =cut 1 + +# vim: sw=3: