--- rxvt-unicode/src/urxvt.pm 2006/08/17 21:56:11 1.146 +++ rxvt-unicode/src/urxvt.pm 2008/11/05 12:45:36 1.173 @@ -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 @@ -100,14 +103,14 @@ 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 first argument. The following will add an entry C that changes -C<$self->{myoption}>: +C<< $self->{myoption} >>: push @{ $self->{term}{option_popup_hook} }, sub { ("my option" => $myoption, sub { $self->{myoption} = $_[0] }) @@ -123,7 +126,7 @@ 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 +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 @@ -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 @@ -164,7 +167,7 @@ A support package that tries to make editing with readline easier. At the moment, it reacts to clicking shift-left mouse button by trying to move the text cursor to this position. It does so by generating as many -cursor-left or cursor-right keypresses as required (the this only works +cursor-left or cursor-right keypresses as required (this only works for programs that correctly support wide characters). To avoid too many false positives, this is only done when: @@ -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,7 +296,7 @@ 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 modifiers, so this @@ -280,14 +305,11 @@ 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. Example: +=item overlay-osc - @@RXVT_NAME@@ -pixmap background.xpm -pe automove-background +This extension implements some OSC commands to display timed popups on the +screen - useful for status displays from within scripts. You have to read +the sources for more info. =item block-graphics-to-ascii @@ -302,7 +324,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 @@ -527,29 +549,42 @@ $nrow - 1) represent the lines to be scrolled out). C<$saved> is the total number of lines that will be in the scrollback buffer. -=item on_osc_seq $term, $op, $args +=item on_osc_seq $term, $op, $args, $resp Called on every OSC sequence and can be used to suppress it or modify its -behaviour. The default should be to return an empty list. A true value +behaviour. The default should be to return an empty list. A true value suppresses execution of the request completely. Make sure you don't get -confused by recursive invocations when you output an osc sequence within +confused by recursive invocations when you output an OSC sequence within this callback. C should be used for new behaviour. -=item on_osc_seq_perl $term, $string +=item on_osc_seq_perl $term, $args, $resp Called whenever the B command sequence (OSC = operating system command) is processed. Cursor position and other state information is up-to-date when this happens. For interoperability, the -string should start with the extension name and a colon, to distinguish -it from commands for other extensions, and this might be enforced in the -future. +string should start with the extension name (sans -osc) and a semicolon, +to distinguish it from commands for other extensions, and this might be +enforced in the future. + +For example, C uses this: + + sub on_osc_seq_perl { + my ($self, $osc, $resp) = @_; + + return unless $osc =~ s/^overlay;//; + + ... process remaining $osc string + } Be careful not ever to trust (in a security sense) the data you receive, as its source can not easily be controlled (e-mail content, messages from other users on the same system etc.). +For responses, C<$resp> contains the end-of-args separator used by the +sender. + =item on_add_lines $term, $string Called whenever text is about to be output, with the text as argument. You @@ -579,8 +614,8 @@ =item on_refresh_begin $term -Called just before the screen gets redrawn. Can be used for overlay -or similar effects by modify terminal contents in refresh_begin, and +Called just before the screen gets redrawn. Can be used for overlay or +similar effects by modifying the terminal contents in refresh_begin, and restoring them in refresh_end. The built-in overlay and selection display code is run after this hook, and takes precedence. @@ -901,7 +936,7 @@ if ($htype == 0) { # INIT my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); - + my %ext_arg; { @@ -974,6 +1009,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; @@ -1052,7 +1112,7 @@ =cut -our $VERSION = 1; +our $VERSION = '3.4'; $INC{"urxvt/anyevent.pm"} = 1; # mark us as there push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; @@ -1093,18 +1153,8 @@ $_[0][1]->stop; } -sub condvar { - bless \my $flag, urxvt::anyevent::condvar:: -} - -sub urxvt::anyevent::condvar::broadcast { - ${$_[0]}++; -} - -sub urxvt::anyevent::condvar::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; @@ -1233,7 +1283,7 @@ to see the actual list: answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont - borderLess color cursorBlink cursorUnderline cutchars delete_key + borderLess chdir color cursorBlink cursorUnderline cutchars delete_key display_name embed ext_bwidth fade font geometry hold iconName imFont imLocale inputMethod insecure int_bwidth intensityStyles italicFont jumpScroll lineSpace loginShell mapAlert meta8 modifier @@ -1242,7 +1292,7 @@ preeditType print_pipe pty_fd reverseVideo saveLines scrollBar scrollBar_align scrollBar_floating scrollBar_right scrollBar_thickness scrollTtyKeypress scrollTtyOutput scrollWithBuffer scrollstyle - secondaryScreen secondaryScroll selectstyle shade term_name title + secondaryScreen secondaryScroll shade term_name title transient_for transparent transparent_all tripleclickwords utmpInhibit visualBell @@ -1251,7 +1301,7 @@ sub resource($$;$) { my ($self, $name) = (shift, shift); unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); - &urxvt::term::_resource + goto &urxvt::term::_resource } =item $value = $term->x_resource ($pattern) @@ -1344,12 +1394,14 @@ =over 4 -=item $overlay->set ($x, $y, $text, $rend) +=item $overlay->set ($x, $y, $text[, $rend]) Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts text in rxvt-unicode's special encoding and an array of rendition values at a specific position inside the overlay. +If C<$rend> is missing, then the rendition will not be changed. + =item $overlay->hide If visible, hide the overlay, but do not destroy it. @@ -1568,10 +1620,9 @@ =item $text = $term->ROW_t ($row_number[, $new_text[, $start_col]]) -Returns the text of the entire row with number C<$row_number>. Row C<0> -is the topmost terminal line, row C<< $term->$ncol-1 >> is the bottommost -terminal line. The scrollback buffer starts at line C<-1> and extends to -line C<< -$term->nsaved >>. Nothing will be returned if a nonexistent line +Returns the text of the entire row with number C<$row_number>. Row C<< $term->top_row >> +is the topmost terminal line, row C<< $term->nrow-1 >> is the bottommost +terminal line. Nothing will be returned if a nonexistent line is requested. If C<$new_text> is specified, it will replace characters in the current @@ -1582,7 +1633,7 @@ C<$text> is in a special encoding: tabs and wide characters that use more than one cell when displayed are padded with C<$urxvt::NOCHAR> (chr 65535) characters. Characters with combining characters and other characters that -do not fit into the normal tetx encoding will be replaced with characters +do not fit into the normal text encoding will be replaced with characters in the private use area. You have to obey this encoding when changing text. The advantage is @@ -1779,7 +1830,7 @@ =item ($type,$format,$octets) = $term->XGetWindowProperty ($window, $property) -=item $term->XChangeWindowProperty ($window, $property, $type, $format, $octets) +=item $term->XChangeProperty ($window, $property, $type, $format, $octets) =item $term->XDeleteProperty ($window, $property) @@ -1911,14 +1962,21 @@ delete $env->{LC_ALL}; $env->{LC_CTYPE} = $self->{term}->locale; - urxvt::term->new ($env, "popup", - "--perl-lib" => "", "--perl-ext-common" => "", - "-pty-fd" => -1, "-sl" => 0, - "-b" => 1, "-bd" => "grey80", "-bl", "-override-redirect", - "--transient-for" => $self->{term}->parent, - "-display" => $self->{term}->display_id, - "-pe" => "urxvt-popup") - or die "unable to create popup window\n"; + my $term = urxvt::term->new ( + $env, "popup", + "--perl-lib" => "", "--perl-ext-common" => "", + "-pty-fd" => -1, "-sl" => 0, + "-b" => 1, "-bd" => "grey80", "-bl", "-override-redirect", + "--transient-for" => $self->{term}->parent, + "-display" => $self->{term}->display_id, + "-pe" => "urxvt-popup", + ) or die "unable to create popup window\n"; + + unless (delete $term->{urxvt_popup_init_done}) { + $term->ungrab; + $term->destroy; + die "unable to initialise popup window\n"; + } } sub DESTROY { @@ -1934,11 +1992,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 @@ -1951,7 +2004,7 @@ ->cb (sub { $term->{overlay}->set (0, 0, sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); - }); + }); =over 4 @@ -2004,7 +2057,7 @@ $term->{iow} = urxvt::iow ->new ->fd (fileno $term->{socket}) - ->events (urxvt::EVENT_READ) + ->events (urxvt::EV_READ) ->start ->cb (sub { my ($iow, $revents) = @_; @@ -2032,8 +2085,8 @@ =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 @@ -2084,7 +2137,7 @@ ->cb (sub { my ($pw, $exit_status) = @_; ... - }); + }); =over 4 @@ -2133,3 +2186,5 @@ =cut 1 + +# vim: sw=3: