--- rxvt-unicode/src/urxvt.pm 2007/12/17 16:57:57 1.162 +++ rxvt-unicode/src/urxvt.pm 2010/03/31 13:14:50 1.183 @@ -110,7 +110,7 @@ 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] }) @@ -305,6 +305,12 @@ If you want a quake-like animation, tell your window manager to do so (fvwm can do it). +=item overlay-osc + +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 A not very useful example of filtering all text output to the terminal @@ -337,7 +343,7 @@ =item selection-pastebin -This is a little rarely useful extension that Uploads the selection as +This is a little rarely useful extension that uploads the selection as textfile to a remote site (or does other things). (The implementation is not currently secure for use in a multiuser environment as it writes to F directly.). @@ -366,9 +372,23 @@ 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 +which works regardless of whether xrdb is used to parse the resource file or not. +=item macosx-clipboard and macosx-clipboard-native + +These two modules implement an extended clipboard for Mac OS X. They are +used like this: + + URxvt.perl-ext-common: default,macosx-clipboard + URxvt.keysym.M-c: perl:macosx-clipboard:copy + URxvt.keysym.M-v: perl:macosx-clipboard:paste + +The difference between them is that the native variant requires a +perl from apple's devkit or so, and C requires the +C module, works with other perls, has fewer bugs, is +simpler etc. etc. + =item example-refresh-hooks Displays a very simple digital clock in the upper right corner of the @@ -399,7 +419,7 @@ =item $text -Rxvt-unicodes special way of encoding text, where one "unicode" character +Rxvt-unicode's special way of encoding text, where one "unicode" character always represents one screen cell. See L for a discussion of this format. =item $string @@ -543,29 +563,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 @@ -595,8 +628,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. @@ -657,8 +690,8 @@ =item on_unmap_notify $term, $event -Called whenever the corresponding X event is received for the terminal If -the hook returns true, then the even will be ignored by rxvt-unicode. +Called whenever the corresponding X event is received for the terminal. If +the hook returns true, then the event will be ignored by rxvt-unicode. The event is a hash with most values as named by Xlib (see the XEvent manpage), with the additional members C and C, which are the @@ -678,6 +711,10 @@ Called when various types of ClientMessage events are received (all with format=32, WM_PROTOCOLS or WM_PROTOCOLS:WM_DELETE_WINDOW). +=item on_bell $term + +Called on receipt of a bell character. + =back =cut @@ -1093,7 +1130,7 @@ =cut -our $VERSION = 1; +our $VERSION = '5.23'; $INC{"urxvt/anyevent.pm"} = 1; # mark us as there push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; @@ -1105,8 +1142,8 @@ urxvt::timer ->new - ->start (urxvt::NOW + $arg{after}) - ->cb (sub { + ->after ($arg{after}, $arg{interval}) + ->cb ($arg{interval} ? $cb : sub { $_[0]->stop; # need to cancel manually $cb->(); }) @@ -1116,36 +1153,46 @@ my ($class, %arg) = @_; my $cb = $arg{cb}; + my $fd = fileno $arg{fh}; + defined $fd or $fd = $arg{fh}; bless [$arg{fh}, urxvt::iow ->new - ->fd (fileno $arg{fh}) + ->fd ($fd) ->events (($arg{poll} =~ /r/ ? 1 : 0) | ($arg{poll} =~ /w/ ? 2 : 0)) ->start - ->cb (sub { - $cb->(($_[1] & 1 ? 'r' : '') - . ($_[1] & 2 ? 'w' : '')); - })], - urxvt::anyevent:: + ->cb ($cb) + ], urxvt::anyevent:: } -sub DESTROY { - $_[0][1]->stop; -} +sub idle { + my ($class, %arg) = @_; + + my $cb = $arg{cb}; -sub condvar { - bless \my $flag, urxvt::anyevent:: + urxvt::iw + ->new + ->start + ->cb ($cb) } -sub broadcast { - ${$_[0]}++; +sub child { + my ($class, %arg) = @_; + + my $cb = $arg{cb}; + + urxvt::pw + ->new + ->start ($arg{pid}) + ->cb (sub { + $_[0]->stop; # need to cancel manually + $cb->($_[0]->rpid, $_[0]->rstatus); + }) } -sub wait { - unless (${$_[0]}) { - Carp::croak "AnyEvent->condvar blocking wait unsupported in urxvt, use a non-blocking API"; - } +sub DESTROY { + $_[0][1]->stop; } sub one_event { @@ -1278,16 +1325,16 @@ 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 - mouseWheelScrollPage name override_redirect pastableTabs path perl_eval - perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay + italicFont jumpScroll lineSpace letterSpace loginShell mapAlert meta8 + modifier mouseWheelScrollPage name override_redirect pastableTabs path + perl_eval perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay 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 @@ -1296,7 +1343,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) @@ -1331,8 +1378,15 @@ =item ($row, $col) = $term->selection_end ([$row, $col]) -Return the current values of the selection mark, begin or end positions, -and optionally set them to new values. +Return the current values of the selection mark, begin or end positions. + +When arguments are given, then the selection coordinates are set to +C<$row> and C<$col>, and the selection screen is set to the current +screen. + +=item $screen = $term->selection_screen ([$screen]) + +Returns the current selection screen, and then optionally sets it. =item $term->selection_make ($eventtime[, $rectangular]) @@ -1389,12 +1443,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. @@ -1613,10 +1669,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 @@ -1812,7 +1867,7 @@ =item $term->ungrab -Calls XUngrab for the most recent grab. Is called automatically on +Calls XUngrabPointer and XUngrabKeyboard for the most recent grab. Is called automatically on evaluation errors, as it is better to lose the grab in the error case as the session. @@ -1824,7 +1879,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) @@ -1844,7 +1899,7 @@ Various X or X-related functions. The C<$term> object only serves as the source of the display, otherwise those functions map more-or-less -directory onto the X functions of the same name. +directly onto the X functions of the same name. =back @@ -1956,14 +2011,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 { @@ -2004,17 +2066,14 @@ Set the callback to be called when the timer triggers. -=item $tstamp = $timer->at - -Return the time this watcher will fire next. - -=item $timer = $timer->set ($tstamp) +=item $timer = $timer->set ($tstamp[, $interval]) -Set the time the event is generated to $tstamp. +Set the time the event is generated to $tstamp (and optionally specifies a +new $interval). =item $timer = $timer->interval ($interval) -Normally (and when C<$interval> is C<0>), the timer will automatically +By default (and when C<$interval> is C<0>), the timer will automatically stop after it has fired once. If C<$interval> is non-zero, then the timer is automatically rescheduled at the given intervals. @@ -2022,11 +2081,12 @@ Start the timer. -=item $timer = $timer->start ($tstamp) +=item $timer = $timer->start ($tstamp[, $interval]) -Set the event trigger time to C<$tstamp> and start the timer. +Set the event trigger time to C<$tstamp> and start the timer. Optionally +also replaces the interval. -=item $timer = $timer->after ($delay) +=item $timer = $timer->after ($delay[, $interval]) Like C, but sets the expiry timer to c.