--- rxvt-unicode/src/urxvt.pm 2007/12/24 08:21:40 1.164 +++ rxvt-unicode/src/urxvt.pm 2011/12/05 12:52:57 1.204 @@ -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] }) @@ -261,14 +261,16 @@ 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. +It is possible to activate the most recently seen match or a list of matches +from the keyboard. Simply bind a keysym to "perl:matcher:last" or +"perl:matcher:list" as seen in the example below. Example configuration: URxvt.perl-ext: default,matcher URxvt.urlLauncher: sensible-browser - URxvt.keysym.C-Delete: perl:matcher + URxvt.keysym.C-Delete: perl:matcher:last + URxvt.keysym.M-Delete: perl:matcher:list URxvt.matcher.button: 1 URxvt.matcher.pattern.1: \\bwww\\.[\\w-]+\\.[\\w./?&@#-]*[\\w/-] URxvt.matcher.pattern.2: \\B(/\\S+?):(\\d+)(?=:|$) @@ -305,6 +307,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 +345,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,15 +374,42 @@ 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 window. Illustrates overwriting the refresh callbacks to create your own overlays or changes. +=item confirm-paste + +Displays a confirmation dialog when a paste containing at least a full +line is detected. + +=item bell-command + +Runs the command specified by the C resource when +a bell event occurs. For example, the following pops up a notification +bubble with the text "Beep, Beep" using notify-send: + + URxvt.bell-command: notify-send "Beep, Beep" + =back =head1 API DOCUMENTATION @@ -399,7 +434,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 @@ -413,12 +448,18 @@ Either binary data or - more common - a text string encoded in a locale-specific way. +=item $keysym + +an integer that is a valid X11 keysym code. You can convert a string +into a keysym and viceversa by using C and +C. + =back =head2 Extension Objects Every perl extension is a perl class. A separate perl object is created -for each terminal, and each terminal has its own set of extenion objects, +for each terminal, and each terminal has its own set of extension 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 @@ -543,29 +584,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,6 +633,13 @@ Called whenever some data is written to the tty/pty and can be used to suppress or filter tty input. +=item on_tt_paste $term, $octets + +Called whenever text is about to be pasted, with the text as argument. You +can filter/change and paste the text yourself by returning a true value +and calling C<< $term->tt_paste >> yourself. C<$octets> is +locale-encoded. + =item on_line_update $term, $row Called whenever a line was updated or changed. Can be used to filter @@ -595,8 +656,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. @@ -613,7 +674,14 @@ The event is simply the action string. This interface is assumed to change slightly in the future. -=item on_resize_all_windows $tern, $new_width, $new_height +=item on_register_command $term, $keysym, $modifiermask, $string + +Called after parsing a keysym resource but before registering the +associated binding. If this hook returns TRUE the binding is not +registered. It can be used to modify a binding by calling +C. + +=item on_resize_all_windows $term, $new_width, $new_height 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 @@ -657,8 +725,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 +746,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 @@ -751,13 +823,14 @@ =item urxvt::fatal $errormessage -Fatally aborts execution with the given error message. Avoid at all -costs! The only time this is acceptable is when the terminal process -starts up. +Fatally aborts execution with the given error message (which should +include a trailing newline). Avoid at all costs! The only time this +is acceptable (and useful) is in the init hook, where it prevents the +terminal from starting up. =item urxvt::warn $string -Calls C with the given string which should not include a +Calls C with the given string which should include a trailing newline. The module also overwrites the C builtin with a function that calls this function. @@ -771,7 +844,7 @@ Returns all urxvt::term objects that exist in this process, regardless of 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). +is no urxvt::term object associated with others). =item $time = urxvt::NOW @@ -824,7 +897,8 @@ Return the rendition mask used for overlays by default. -=item $rendbit = urxvt::RS_Bold, RS_Italic, RS_Blink, RS_RVid, RS_Uline +=item $rendbit = urxvt::RS_Bold, urxvt::RS_Italic, urxvt::RS_Blink, +urxvt::RS_RVid, urxvt::RS_Uline Return the bit that enabled bold, italic, blink, reverse-video and underline, respectively. To enable such a style, just logically OR it into @@ -916,7 +990,7 @@ my $htype = shift; if ($htype == 0) { # INIT - my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); + my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$ENV{HOME}/.urxvt/ext", "$LIBDIR/perl"); my %ext_arg; @@ -1093,7 +1167,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 +1179,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,38 +1190,49 @@ 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) = @_; -sub condvar { - bless \my $flag, urxvt::anyevent:: + my $cb = $arg{cb}; + + 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; } +# only needed for AnyEvent < 6 compatibility sub one_event { Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a non-blocking API"; } @@ -1249,12 +1334,13 @@ 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 - intensityStyles jumpScroll loginShell mapAlert meta8 mouseWheelScrollPage - override-redirect pastableTabs pointerBlank reverseVideo scrollBar - scrollBar_floating scrollBar_right scrollTtyKeypress scrollTtyOutput - scrollWithBuffer secondaryScreen secondaryScroll skipBuiltinGlyphs - transparent tripleclickwords utmpInhibit visualBell + borderLess buffered console cursorBlink cursorUnderline hold iconic + insecure intensityStyles iso14755 iso14755_52 jumpScroll loginShell + mapAlert meta8 mouseWheelScrollPage override_redirect pastableTabs + pointerBlank reverseVideo scrollBar scrollBar_floating scrollBar_right + scrollTtyKeypress scrollTtyOutput scrollWithBuffer secondaryScreen + secondaryScroll skipBuiltinGlyphs skipScroll transparent tripleclickwords + urgentOnBell utmpInhibit visualBell =item $value = $term->resource ($name[, $newval]) @@ -1277,26 +1363,27 @@ are supported in every build, please see the source file F to see the actual list: - answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont - borderLess 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 + answerbackstring backgroundPixmap backspace_key blendtype blurradius + boldFont boldItalicFont borderLess buffered chdir color cursorBlink + cursorUnderline cutchars delete_key depth display_name embed ext_bwidth + fade font geometry hold iconName iconfile imFont imLocale inputMethod + insecure int_bwidth intensityStyles iso14755 iso14755_52 italicFont + jumpScroll letterSpace lineSpace 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 shade term_name title - transient_for transparent transparent_all tripleclickwords utmpInhibit - visualBell + secondaryScreen secondaryScroll shade skipBuiltinGlyphs skipScroll + term_name title transient_for transparent tripleclickwords urgentOnBell + utmpInhibit visualBell =cut 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) @@ -1310,11 +1397,18 @@ only one resource database per display, and later invocations might return the wrong resources. -=item $success = $term->parse_keysym ($keysym_spec, $command_string) +=item $success = $term->parse_keysym ($key, $octets) -Adds a keymap translation exactly as specified via a resource. See the +Adds a key binding exactly as specified via a resource. See the C resource in the @@RXVT_NAME@@(1) manpage. +=item $term->register_command ($keysym, $modifiermask, $string) + +Adds a key binding. This is a lower level api compared to +C, as it expects a parsed key description, and can be +used only inside either the C hook, to add a binding, or the +C hook, to modify a parsed binding. + =item $rend = $term->rstyle ([$new_rstyle]) Return and optionally change the current rendition. Text that is output by @@ -1331,25 +1425,38 @@ =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]) Tries to make a selection as set by C and C. If C<$rectangular> is true (default: false), a -rectangular selection will be made. This is the prefered function to make +rectangular selection will be made. This is the preferred function to make a selection. -=item $success = $term->selection_grab ($eventtime) +=item $success = $term->selection_grab ($eventtime[, $clipboard]) -Try to request the primary selection text from the server (for example, as -set by the next method). No visual feedback will be given. This function +Try to acquire ownership of the primary (clipboard if C<$clipboard> is +true) selection from the server. The corresponding text can be set +with the next method. No visual feedback will be given. This function is mostly useful from within C hooks. -=item $oldtext = $term->selection ([$newtext]) +=item $oldtext = $term->selection ([$newtext, $clipboard]) -Return the current selection text and optionally replace it by C<$newtext>. +Return the current selection (clipboard if C<$clipboard> is true) text +and optionally replace it by C<$newtext>. + +=item $term->selection_clear ([$clipboard]) + +Revoke ownership of the primary (clipboard if C<$clipboard> is true) selection. =item $term->overlay_simple ($x, $y, $text) @@ -1389,12 +1496,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. @@ -1485,10 +1594,16 @@ =item $term->tt_write ($octets) -Write the octets given in C<$data> to the tty (i.e. as program input). To +Write the octets given in C<$octets> to the tty (i.e. as program input). To pass characters instead of octets, you should convert your strings first to the locale-specific encoding using C<< $term->locale_encode >>. +=item $term->tt_paste ($octets) + +Write the octets given in C<$octets> to the tty as a paste, converting NL to +CR and bracketing the data with control sequences if bracketed paste mode +is set. + =item $old_events = $term->pty_ev_events ([$new_events]) Replaces the event mask of the pty watcher by the given event mask. Can @@ -1516,6 +1631,10 @@ $term->vt_emask_add (urxvt::PointerMotionMask); +=item $term->set_urgency ($set) + +Enable/disable the urgency hint on the toplevel window. + =item $term->focus_in =item $term->focus_out @@ -1613,10 +1732,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 +1930,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 +1942,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) @@ -1842,9 +1960,13 @@ =item $term->XChangeInput ($window, $add_events[, $del_events]) +=item $keysym = $term->XStringToKeysym ($string) + +=item $string = $term->XKeysymToString ($keysym) + 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 @@ -2011,17 +2133,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. @@ -2029,11 +2148,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. @@ -2174,7 +2294,7 @@ =head1 AUTHOR - Marc Lehmann + Marc Lehmann http://software.schmorp.de/pkg/rxvt-unicode =cut