From 0533cca29dd9d4130872cfed7208c4560c596d43 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Jan 2006 02:13:55 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 4 +- doc/rxvt.1.html | 7 ++ doc/rxvt.1.man.in | 6 +- doc/rxvt.1.pod | 5 + doc/rxvt.1.txt | 4 + doc/rxvtperl.3.html | 30 ++++-- doc/rxvtperl.3.man.in | 40 ++++---- doc/rxvtperl.3.txt | 166 +++++++++++++++++---------------- src/command.C | 20 +--- src/feature.h | 6 -- src/perl/mark-urls | 40 ++++---- src/perl/searchable-scrollback | 6 +- src/perl/selection-popup | 4 +- src/rxvt.h | 1 + src/rxvtperl.xs | 5 + src/screen.C | 3 - src/urxvt.pm | 25 +++-- src/xdefaults.C | 54 +++++------ 18 files changed, 239 insertions(+), 187 deletions(-) diff --git a/Changes b/Changes index 512a5925..6a924f41 100644 --- a/Changes +++ b/Changes @@ -5,13 +5,11 @@ TODO: after requesting the selection and getting a timeout, no further requests TODO: "slow" rendering mode for bidi and scripts TODO: read property sequence is broken with respect to utf-8 etc. TODO: http://www120.pair.com/mccarthy/nextstep/intro.htmld/Workspace.html is the correct nextstep look. +TODO: clarify and get rid of SMOOTH_REFRESH etc. WISH: OnTheSpot editing, or maybe switch to miiiiiiif WISH: just for fun, do shade and tint with XRender. WISH: support tex fonts -TODO: resources! resources! resources! -TODO: better environment handling in rxvt/xim etc. and urxvt::term->new -TODO: selection-extending with rmb does not work? - added sections for DISTRIBUTION MAINTAINERS and about SETUID/SETGID to the FAQ. - selection, searchable-scrollback, selection-popup and diff --git a/doc/rxvt.1.html b/doc/rxvt.1.html index 08ca3471..6c4ac4b0 100644 --- a/doc/rxvt.1.html +++ b/doc/rxvt.1.html @@ -1504,6 +1504,13 @@ will be ignored when running setuid/setgid.

See the rxvtperl(3) manpage.

+
urlLauncher: string
+
+
+Specifies the program to be started with a URL argument. Used by the +selection-popup and mark-urls perl extensions. +
+

transient-for: windowid
diff --git a/doc/rxvt.1.man.in b/doc/rxvt.1.man.in index b94e7204..c727954a 100644 --- a/doc/rxvt.1.man.in +++ b/doc/rxvt.1.man.in @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "rxvt 1" -.TH rxvt 1 "2006-01-10" "6.3" "RXVT-UNICODE" +.TH rxvt 1 "2006-01-11" "6.3" "RXVT-UNICODE" .SH "NAME" rxvt\-unicode (ouR XVT, unicode) \- (a VT102 emulator for the X window system) .SH "SYNOPSIS" @@ -1148,6 +1148,10 @@ scripts. When looking for extensions specified by the \f(CW\*(C`perl\*(C'\fR res will be ignored when running setuid/setgid. .Sp See the @@RXVT_NAME@@\fIperl\fR\|(3) manpage. +.IP "\fBurlLauncher\fR: \fIstring\fR" 4 +.IX Item "urlLauncher: string" +Specifies the program to be started with a \s-1URL\s0 argument. Used by the +\&\f(CW\*(C`selection\-popup\*(C'\fR and \f(CW\*(C`mark\-urls\*(C'\fR perl extensions. .IP "\fBtransient-for\fR: \fIwindowid\fR" 4 .IX Item "transient-for: windowid" Sets the \s-1WM_TRANSIENT_FOR\s0 property to the given window iw. diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod index 250d8736..f89560fd 100644 --- a/doc/rxvt.1.pod +++ b/doc/rxvt.1.pod @@ -1125,6 +1125,11 @@ will be ignored when running setuid/setgid. See the @@RXVT_NAME@@perl(3) manpage. +=item B: I + +Specifies the program to be started with a URL argument. Used by the +C and C perl extensions. + =item B: I Sets the WM_TRANSIENT_FOR property to the given window iw. diff --git a/doc/rxvt.1.txt b/doc/rxvt.1.txt index 82f3fe2c..d21bca73 100644 --- a/doc/rxvt.1.txt +++ b/doc/rxvt.1.txt @@ -981,6 +981,10 @@ RESOURCES (available also as long-options) See the rxvtperl(3) manpage. + urlLauncher: *string* + Specifies the program to be started with a URL argument. Used by the + "selection-popup" and "mark-urls" perl extensions. + transient-for: *windowid* Sets the WM_TRANSIENT_FOR property to the given window iw. diff --git a/doc/rxvtperl.3.html b/doc/rxvtperl.3.html index ec9d00b1..6dbda25b 100644 --- a/doc/rxvtperl.3.html +++ b/doc/rxvtperl.3.html @@ -143,7 +143,9 @@ Displays a digital clock using the built-in overlay.
mark-urls
-Uses per-line display filtering (on_line_update) to underline urls. +Uses per-line display filtering (on_line_update) to underline urls and +make them clickable. When clicked, the program specified in the resource +urlLauncher (default x-www-browser) will be started.

block-graphics-to-ascii
@@ -185,7 +187,7 @@ hints on what they mean:

Rxvt-unicodes special way of encoding text, where one ``unicode'' character -always represents one screen cell. See row_t for a discussion of this format. +always represents one screen cell. See ROW_t for a discussion of this format.

$string
@@ -478,9 +480,7 @@ The basename of the installed binaries, usually urxvt. The current terminal. This variable stores the current urxvt::term object, whenever a callback/hook is executing. -

-
- +

Functions in the urxvt Package

@@ -611,11 +611,11 @@ work.

Creates a new terminal, very similar as if you had started it with system -$rxvtname, arg.... $envhashref must be a reference to a %ENV>-like -hash which defines the environment of the new terminal. +$rxvtname, arg.... $envhashref must be a reference to a %ENV-like +hash which defines the environment of the new terminal.
-

>Croaks (and probably outputs an error message) if the new instance +

Croaks (and probably outputs an error message) if the new instance couldn't be created. Returns undef if the new instance didn't initialise perl, and the terminal object otherwise. The init and start hooks will be called during this call.

@@ -692,6 +692,20 @@ to see the actual list:

utmpInhibit visualBell

+
$value = $term->x_resource ($pattern)
+
+
+Returns the X-Resource for the given pattern, excluding the program or +class name, i.e. $term->x_resource ("boldFont") should return the +same value as used by this instance of rxvt-unicode. Returns undef if no +resource with that pattern exists. +
+
+

This method should only be called during the on_start hook, as there is +only one resource database per display, and later invocations might return +the wrong resources.

+
+

$success = $term->parse_keysym ($keysym_spec, $command_string)
diff --git a/doc/rxvtperl.3.man.in b/doc/rxvtperl.3.man.in index 7cec2735..fc0d7d27 100644 --- a/doc/rxvtperl.3.man.in +++ b/doc/rxvtperl.3.man.in @@ -215,7 +215,9 @@ returns to the original position. Displays a digital clock using the built-in overlay. .IP "mark-urls" 4 .IX Item "mark-urls" -Uses per-line display filtering (\f(CW\*(C`on_line_update\*(C'\fR) to underline urls. +Uses per-line display filtering (\f(CW\*(C`on_line_update\*(C'\fR) to underline urls and +make them clickable. When clicked, the program specified in the resource +\&\f(CW\*(C`urlLauncher\*(C'\fR (default \f(CW\*(C`x\-www\-browser\*(C'\fR) will be started. .IP "block-graphics-to-ascii" 4 .IX Item "block-graphics-to-ascii" A not very useful example of filtering all text output to the terminal, @@ -246,7 +248,7 @@ hints on what they mean: .IP "$text" 4 .IX Item "$text" Rxvt-unicodes special way of encoding text, where one \*(L"unicode\*(R" character -always represents one screen cell. See row_t for a discussion of this format. +always represents one screen cell. See ROW_t for a discussion of this format. .IP "$string" 4 .IX Item "$string" A perl text string, with an emphasis on \fItext\fR. It can store all unicode @@ -477,15 +479,12 @@ The basename of the installed binaries, usually \f(CW\*(C`urxvt\*(C'\fR. .IX Item "$urxvt::TERM" The current terminal. This variable stores the current \f(CW\*(C`urxvt::term\*(C'\fR object, whenever a callback/hook is executing. -.IP "*" 4 .ie n .Sh "Functions in the ""urxvt"" Package" .el .Sh "Functions in the \f(CWurxvt\fP Package" .IX Subsection "Functions in the urxvt Package" -.PD 0 .ie n .IP "urxvt::fatal $errormessage" 4 .el .IP "urxvt::fatal \f(CW$errormessage\fR" 4 .IX Item "urxvt::fatal $errormessage" -.PD 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. @@ -581,11 +580,10 @@ work. .el .IP "$term = new urxvt::term \f(CW$envhashref\fR, \f(CW$rxvtname\fR, [arg...]" 4 .IX Item "$term = new urxvt::term $envhashref, $rxvtname, [arg...]" Creates a new terminal, very similar as if you had started it with system -\&\f(CW\*(C`$rxvtname, arg...\*(C'\fR. \f(CW$envhashref\fR must be a reference to a \f(CW%ENV\fR>\-like -\&\f(CW\*(C`hash which defines the environment of the new terminal. - -\&\*(C'\fR.Sp ->Croaks (and probably outputs an error message) if the new instance +\&\f(CW\*(C`$rxvtname, arg...\*(C'\fR. \f(CW$envhashref\fR must be a reference to a \f(CW%ENV\fR\-like +hash which defines the environment of the new terminal. +.Sp +Croaks (and probably outputs an error message) if the new instance couldn't be created. Returns \f(CW\*(C`undef\*(C'\fR if the new instance didn't initialise perl, and the terminal object otherwise. The \f(CW\*(C`init\*(C'\fR and \&\f(CW\*(C`start\*(C'\fR hooks will be called during this call. @@ -648,6 +646,17 @@ to see the actual list: \& shade term_name title transparent transparent_all tripleclickwords \& utmpInhibit visualBell .Ve +.ie n .IP "$value = $term\->x_resource ($pattern)" 4 +.el .IP "$value = \f(CW$term\fR\->x_resource ($pattern)" 4 +.IX Item "$value = $term->x_resource ($pattern)" +Returns the X\-Resource for the given pattern, excluding the program or +class name, i.e. \f(CW\*(C`$term\->x_resource ("boldFont")\*(C'\fR should return the +same value as used by this instance of rxvt\-unicode. Returns \f(CW\*(C`undef\*(C'\fR if no +resource with that pattern exists. +.Sp +This method should only be called during the \f(CW\*(C`on_start\*(C'\fR hook, as there is +only one resource database per display, and later invocations might return +the wrong resources. .ie n .IP "$success = $term\fR\->parse_keysym ($keysym_spec, \f(CW$command_string)" 4 .el .IP "$success = \f(CW$term\fR\->parse_keysym ($keysym_spec, \f(CW$command_string\fR)" 4 .IX Item "$success = $term->parse_keysym ($keysym_spec, $command_string)" @@ -1022,7 +1031,7 @@ Displays the popup (which is initially hidden). .IX Subsection "The urxvt::timer Class" This class implements timer watchers/events. Time is represented as a fractional number of seconds since the epoch. Example: -.Sp +.PP .Vb 8 \& $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0); \& $term->{timer} = urxvt::timer @@ -1033,7 +1042,6 @@ fractional number of seconds since the epoch. Example: \& sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); \& }); .Ve -.RS 4 .IP "$timer = new urxvt::timer" 4 .IX Item "$timer = new urxvt::timer" Create a new timer object in started state. It is scheduled to fire @@ -1068,13 +1076,11 @@ Set the event trigger time to \f(CW$tstamp\fR and start the timer. .el .IP "$timer = \f(CW$timer\fR\->stop" 4 .IX Item "$timer = $timer->stop" Stop the timer. -.RE -.RS 4 .ie n .Sh "The ""urxvt::iow"" Class" .el .Sh "The \f(CWurxvt::iow\fP Class" .IX Subsection "The urxvt::iow Class" This class implements io watchers/events. Example: -.Sp +.PP .Vb 12 \& $term->{socket} = ... \& $term->{iow} = urxvt::iow @@ -1115,8 +1121,6 @@ Start watching for requested events on the given handle. .el .IP "$iow = \f(CW$iow\fR\->stop" 4 .IX Item "$iow = $iow->stop" Stop watching for events on the given filehandle. -.RE -.RS 4 .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .Sh "\s-1URXVT_PERL_VERBOSITY\s0" @@ -1130,8 +1134,6 @@ numbers indicate more verbose output. .IX Item ">= 3 - script loading and management" .IP ">=10 \- all events received" 4 .IX Item ">=10 - all events received" -.RE -.RS 4 .PD .SH "AUTHOR" .IX Header "AUTHOR" diff --git a/doc/rxvtperl.3.txt b/doc/rxvtperl.3.txt index 1246f021..e33777a8 100644 --- a/doc/rxvtperl.3.txt +++ b/doc/rxvtperl.3.txt @@ -69,8 +69,9 @@ PREPACKAGED EXTENSIONS Displays a digital clock using the built-in overlay. mark-urls - Uses per-line display filtering ("on_line_update") to underline - urls. + Uses per-line display filtering ("on_line_update") to underline urls + and make them clickable. When clicked, the program specified in the + resource "urlLauncher" (default "x-www-browser") will be started. block-graphics-to-ascii A not very useful example of filtering all text output to the @@ -100,7 +101,7 @@ API DOCUMENTATION $text Rxvt-unicodes special way of encoding text, where one "unicode" - character always represents one screen cell. See row_t for a + character always represents one screen cell. See ROW_t for a discussion of this format. $string @@ -301,8 +302,6 @@ API DOCUMENTATION The current terminal. This variable stores the current "urxvt::term" object, whenever a callback/hook is executing. - * - Functions in the "urxvt" Package urxvt::fatal $errormessage Fatally aborts execution with the given error message. Avoid at all @@ -384,10 +383,9 @@ API DOCUMENTATION $term = new urxvt::term $envhashref, $rxvtname, [arg...] Creates a new terminal, very similar as if you had started it with system "$rxvtname, arg...". $envhashref must be a reference to a - %ENV>-like "hash which defines the environment of the new terminal. - " + %ENV-like hash which defines the environment of the new terminal. - >Croaks (and probably outputs an error message) if the new instance + Croaks (and probably outputs an error message) if the new instance couldn't be created. Returns "undef" if the new instance didn't initialise perl, and the terminal object otherwise. The "init" and "start" hooks will be called during this call. @@ -447,6 +445,16 @@ API DOCUMENTATION shade term_name title transparent transparent_all tripleclickwords utmpInhibit visualBell + $value = $term->x_resource ($pattern) + Returns the X-Resource for the given pattern, excluding the program + or class name, i.e. "$term->x_resource ("boldFont")" should return + the same value as used by this instance of rxvt-unicode. Returns + "undef" if no resource with that pattern exists. + + This method should only be called during the "on_start" hook, as + there is only one resource database per display, and later + invocations might return the wrong resources. + $success = $term->parse_keysym ($keysym_spec, $command_string) Adds a keymap translation exactly as specified via a resource. See the "keysym" resource in the rxvt(1) manpage. @@ -738,92 +746,92 @@ API DOCUMENTATION Displays the popup (which is initially hidden). The "urxvt::timer" Class - This class implements timer watchers/events. Time is represented as - a fractional number of seconds since the epoch. Example: + This class implements timer watchers/events. Time is represented as a + fractional number of seconds since the epoch. Example: - $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0); - $term->{timer} = urxvt::timer - ->new - ->interval (1) - ->cb (sub { - $term->{overlay}->set (0, 0, - sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); - }); + $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0); + $term->{timer} = urxvt::timer + ->new + ->interval (1) + ->cb (sub { + $term->{overlay}->set (0, 0, + sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]); + }); - $timer = new urxvt::timer - Create a new timer object in started state. It is scheduled to - fire immediately. + $timer = new urxvt::timer + Create a new timer object in started state. It is scheduled to fire + immediately. - $timer = $timer->cb (sub { my ($timer) = @_; ... }) - Set the callback to be called when the timer triggers. + $timer = $timer->cb (sub { my ($timer) = @_; ... }) + Set the callback to be called when the timer triggers. - $tstamp = $timer->at - Return the time this watcher will fire next. + $tstamp = $timer->at + Return the time this watcher will fire next. - $timer = $timer->set ($tstamp) - Set the time the event is generated to $tstamp. + $timer = $timer->set ($tstamp) + Set the time the event is generated to $tstamp. - $timer = $timer->interval ($interval) - Normally (and when $interval is 0), the timer will automatically - stop after it has fired once. If $interval is non-zero, then the - timer is automatically rescheduled at the given intervals. + $timer = $timer->interval ($interval) + Normally (and when $interval is 0), the timer will automatically + stop after it has fired once. If $interval is non-zero, then the + timer is automatically rescheduled at the given intervals. - $timer = $timer->start - Start the timer. + $timer = $timer->start + Start the timer. - $timer = $timer->start ($tstamp) - Set the event trigger time to $tstamp and start the timer. + $timer = $timer->start ($tstamp) + Set the event trigger time to $tstamp and start the timer. - $timer = $timer->stop - Stop the timer. + $timer = $timer->stop + Stop the timer. The "urxvt::iow" Class - This class implements io watchers/events. Example: - - $term->{socket} = ... - $term->{iow} = urxvt::iow - ->new - ->fd (fileno $term->{socket}) - ->events (urxvt::EVENT_READ) - ->start - ->cb (sub { - my ($iow, $revents) = @_; - # $revents must be 1 here, no need to check - sysread $term->{socket}, my $buf, 8192 - or end-of-file; - }); - - $iow = new urxvt::iow - Create a new io watcher object in stopped state. - - $iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... }) - Set the callback to be called when io events are triggered. - $reventmask is a bitset as described in the "events" method. - - $iow = $iow->fd ($fd) - Set the filedescriptor (not handle) to watch. - - $iow = $iow->events ($eventmask) - Set the event mask to watch. The only allowed values are - "urxvt::EVENT_READ" and "urxvt::EVENT_WRITE", which might be - ORed together, or "urxvt::EVENT_NONE". - - $iow = $iow->start - Start watching for requested events on the given handle. - - $iow = $iow->stop - Stop watching for events on the given filehandle. + This class implements io watchers/events. Example: + + $term->{socket} = ... + $term->{iow} = urxvt::iow + ->new + ->fd (fileno $term->{socket}) + ->events (urxvt::EVENT_READ) + ->start + ->cb (sub { + my ($iow, $revents) = @_; + # $revents must be 1 here, no need to check + sysread $term->{socket}, my $buf, 8192 + or end-of-file; + }); + + $iow = new urxvt::iow + Create a new io watcher object in stopped state. + + $iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... }) + Set the callback to be called when io events are triggered. + $reventmask is a bitset as described in the "events" method. + + $iow = $iow->fd ($fd) + Set the filedescriptor (not handle) to watch. + + $iow = $iow->events ($eventmask) + Set the event mask to watch. The only allowed values are + "urxvt::EVENT_READ" and "urxvt::EVENT_WRITE", which might be ORed + together, or "urxvt::EVENT_NONE". + + $iow = $iow->start + Start watching for requested events on the given handle. + + $iow = $iow->stop + Stop watching for events on the given filehandle. ENVIRONMENT URXVT_PERL_VERBOSITY - This variable controls the verbosity level of the perl extension. - Higher numbers indicate more verbose output. + This variable controls the verbosity level of the perl extension. Higher + numbers indicate more verbose output. - == 0 - fatal messages - >= 3 - script loading and management - >=10 - all events received + == 0 - fatal messages + >= 3 - script loading and management + >=10 - all events received AUTHOR - Marc Lehmann - http://software.schmorp.de/pkg/rxvt-unicode + Marc Lehmann + http://software.schmorp.de/pkg/rxvt-unicode diff --git a/src/command.C b/src/command.C index 7ca194df..8011f828 100644 --- a/src/command.C +++ b/src/command.C @@ -987,7 +987,7 @@ rxvt_term::flush () do { - l = &ROW (row++); + l = &ROW (row); if (l->f & LINE_FILTERED) row++; @@ -1575,7 +1575,7 @@ rxvt_term::x_cb (XEvent &ev) scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); - scr_refresh (refresh_type); + want_refresh = 1; } else { @@ -1712,7 +1712,7 @@ rxvt_term::x_cb (XEvent &ev) &unused_mask); scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, scrollbar_size ()); - scr_refresh (refresh_type); + want_refresh = 1; refresh_limit = 0; scrollbar_show (1); } @@ -2218,21 +2218,11 @@ rxvt_term::button_release (XButtonEvent &ev) else { # endif -# ifdef JUMP_MOUSE_WHEEL scr_page (v, i); - scr_refresh (SMOOTH_REFRESH); scrollbar_show (1); -# else - while (i--) - { - scr_page (v, 1); - scr_refresh (SMOOTH_REFRESH); - scrollbar_show (1); - } -# endif # ifdef MOUSE_SLIP_WHEELING } -#endif +# endif } break; #endif @@ -2836,7 +2826,7 @@ rxvt_term::cmd_parse () { flag = true; scr_refresh (refresh_type); - flush_ev.stop (); + want_refresh = 1; } } diff --git a/src/feature.h b/src/feature.h index acb8097e..25572037 100644 --- a/src/feature.h +++ b/src/feature.h @@ -223,12 +223,6 @@ */ #define MOUSE_THRESHOLD 50 -/* - * If mouse wheel is defined, then scrolling is by 5 lines (or 1 line - * if the shift key is down). Scrolling can be smooth or jump scrolling - */ -#define JUMP_MOUSE_WHEEL - /* * Set delay periods for continuous scrolling with scrollbar buttons */ diff --git a/src/perl/mark-urls b/src/perl/mark-urls index 644ad7e1..83cb99c3 100644 --- a/src/perl/mark-urls +++ b/src/perl/mark-urls @@ -7,6 +7,12 @@ my $url = [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) )}x; +sub on_start { + my ($self) = @_; + + $self->{browser} = urxvt::untaint $self->x_resource ("urlLauncher") || "x-www-browser"; +} + sub on_line_update { my ($self, $row) = @_; @@ -29,22 +35,20 @@ sub on_line_update { () } -# needs confgiurability TODO -#sub on_button_press { -# my ($self, $event) = @_; -# my $row = $event->{row}; -# my $col = $event->{col}; -# -# my $line = $self->line ($row); -# my $text = $line->t; -# -# while($text =~ /$url/g) { -# #print "... " . ($-[0] -# if ($-[0] <= $col && $+[0] >= $col) { -# system "firefox \Q$1\E &"; -# return 1; -# } -# } -# () -#} +sub on_button_press { + my ($self, $event) = @_; + my $row = $event->{row}; + my $col = $event->{col}; + + my $line = $self->line ($row); + my $text = $line->t; + + while($text =~ /$url/g) { + if ($-[0] <= $col && $+[0] >= $col) { + system "$self->{browser} \Q$1\E &"; + return 1; + } + } + () +} diff --git a/src/perl/searchable-scrollback b/src/perl/searchable-scrollback index 66274e91..88b99f39 100644 --- a/src/perl/searchable-scrollback +++ b/src/perl/searchable-scrollback @@ -5,7 +5,9 @@ sub on_init { my ($self) = @_; - my $hotkey = $self->{argv}[0] || "M-s"; + my $hotkey = $self->{argv}[0] + || $self->x_resource ("searchable-scrollback") + || "M-s"; $self->parse_keysym ($hotkey, "perl:searchable-scrollback:start") or warn "unable to register '$hotkey' as scrollback search start hotkey\n"; @@ -46,7 +48,7 @@ sub enter { ); $self->{manpage_overlay} = $self->overlay (0, -2, $self->ncol, 1, urxvt::OVERLAY_RSTYLE, 0); - $self->{manpage_overlay}->set (0, 0, "scrollback search, see man ${urxvt::RXVTNAME}perl"); + $self->{manpage_overlay}->set (0, 0, "scrollback search, see the ${urxvt::RXVTNAME}perl manpage for details"); $self->idle; } diff --git a/src/perl/selection-popup b/src/perl/selection-popup index e5984873..5bc679f5 100644 --- a/src/perl/selection-popup +++ b/src/perl/selection-popup @@ -14,6 +14,8 @@ sub msg { sub on_start { my ($self) = @_; + $self->{browser} = urxvt::untaint $self->x_resource ("urlLauncher") || "x-www-browser"; + $self->grab_button (3, urxvt::ControlMask); } @@ -67,7 +69,7 @@ sub on_button_press { and $add_button->("shell quote" => sub { $_ = "\Q$_" }); /^(http|ftp|telnet|irc|news):\// - and $add_button->("run x-www-browser" => sub { system "x-www-browser \Q$_\E &" }); + and $add_button->("run $self->{browser}" => sub { system "$self->{browser} \Q$_\E &" }); } $popup->show; diff --git a/src/rxvt.h b/src/rxvt.h index 82c47db8..33f5109c 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1258,6 +1258,7 @@ struct rxvt_term : zero_initialized, rxvt_vars { void init_secondary (); const char **init_resources (int argc, const char *const *argv); + const char *x_resource (const char *name); void init_env (); void set_locale (const char *locale); void init_xlocale (); diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs index 69a62de9..ddc65381 100644 --- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -1278,6 +1278,11 @@ rxvt_term::_resource (char *name, int index, SV *newval = 0) } } +const char * +rxvt_term::x_resource (const char *name) + CLEANUP: + SvTAINTED_on (ST (0)); + bool rxvt_term::option (U32 optval, int set = -1) CODE: diff --git a/src/screen.C b/src/screen.C index c06d47c7..1478194c 100644 --- a/src/screen.C +++ b/src/screen.C @@ -2383,9 +2383,6 @@ rxvt_term::scr_refresh (unsigned char refresh_type) */ scr_reverse_selection (); - if (refresh_type & SMOOTH_REFRESH) - XFlush (display->display); - num_scr = 0; num_scr_allow = 1; } diff --git a/src/urxvt.pm b/src/urxvt.pm index 46f3fa56..4106cbc6 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -86,7 +86,9 @@ Displays a digital clock using the built-in overlay. =item mark-urls -Uses per-line display filtering (C) to underline urls. +Uses per-line display filtering (C) to underline urls and +make them clickable. When clicked, the program specified in the resource +C (default C) will be started. =item block-graphics-to-ascii @@ -125,7 +127,7 @@ hints on what they mean: =item $text Rxvt-unicodes special way of encoding text, where one "unicode" character -always represents one screen cell. See L for a discussion of this format. +always represents one screen cell. See L for a discussion of this format. =item $string @@ -388,8 +390,6 @@ The basename of the installed binaries, usually C. The current terminal. This variable stores the current C object, whenever a callback/hook is executing. -=item - =back =head2 Functions in the C Package @@ -784,8 +784,8 @@ sub register_package { =item $term = new urxvt::term $envhashref, $rxvtname, [arg...] Creates a new terminal, very similar as if you had started it with system -C<$rxvtname, arg...>. C<$envhashref> must be a reference to a %ENV>-like -C. C<$envhashref> must be a reference to a C<%ENV>-like +hash which defines the environment of the new terminal. Croaks (and probably outputs an error message) if the new instance couldn't be created. Returns C if the new instance didn't @@ -864,6 +864,17 @@ sub resource($$;$) { &urxvt::term::_resource } +=item $value = $term->x_resource ($pattern) + +Returns the X-Resource for the given pattern, excluding the program or +class name, i.e. C<< $term->x_resource ("boldFont") >> should return the +same value as used by this instance of rxvt-unicode. Returns C if no +resource with that pattern exists. + +This method should only be called during the C hook, as there is +only one resource database per display, and later invocations might return +the wrong resources. + =item $success = $term->parse_keysym ($keysym_spec, $command_string) Adds a keymap translation exactly as specified via a resource. See the @@ -1444,6 +1455,8 @@ sub DESTROY { $self->{term}->ungrab; } +=back + =head2 The C Class This class implements timer watchers/events. Time is represented as a diff --git a/src/xdefaults.C b/src/xdefaults.C index d83b008f..1f2d5f35 100644 --- a/src/xdefaults.C +++ b/src/xdefaults.C @@ -773,7 +773,8 @@ rxvt_term::parse_keysym (const char *str, const char *arg) # endif /* KEYSYM_RESOURCE */ #endif /* NO_RESOURCES */ -char *get_res (XrmDatabase database, const char *program, const char *option) +static char * +get_res (XrmDatabase database, const char *program, const char *option) { char resource[512]; char *type; @@ -785,49 +786,50 @@ char *get_res (XrmDatabase database, const char *program, const char *option) return result.addr; } -/*{{{ read the resources files */ -/* - * using XGetDefault () or the hand-rolled replacement - */ -/* ARGSUSED */ +const char * +rxvt_term::x_resource (const char *name) +{ + XrmDatabase database = XrmGetDatabase (display->display); + + const char *p = get_res (database, rs[Rs_name], name); + const char *p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", name); + + if (p == NULL || (p0 && strcmp (p, p0) == 0)) + { + p = get_res (database, RESCLASS, name); +#ifdef RESFALLBACK + if (p == NULL || (p0 && strcmp (p, p0) == 0)) + p = get_res (database, RESFALLBACK, name); +#endif + } + + if (p == NULL && p0) + p = p0; + + return p; +} + void rxvt_term::extract_resources () { - dDisp; - #ifndef NO_RESOURCES - XrmDatabase database = XrmGetDatabase (display->display); - /* * Query resources for options that affect us */ for (int entry = 0; entry < optList_size; entry++) { int s; - char *p, *p0; const char *kw = optList[entry].kw; if (kw == NULL || rs[optList[entry].doff] != NULL) continue; // previously set - p = get_res (database, rs[Rs_name], kw); - p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); - if (p == NULL || (p0 && strcmp (p, p0) == 0)) - { - p = get_res (database, RESCLASS, kw); -#ifdef RESFALLBACK - if (p == NULL || (p0 && strcmp (p, p0) == 0)) - p = get_res (database, RESFALLBACK, kw); -#endif - } - - if (p == NULL && p0) - p = p0; + const char *p = x_resource (kw); if (p) { p = strdup (p); - allocated.push_back (p); + allocated.push_back ((void *)p); rs[optList[entry].doff] = p; if (optList_isBool (entry)) @@ -849,6 +851,7 @@ rxvt_term::extract_resources () * [R5 or later]: enumerate the resource database */ # ifdef KEYSYM_RESOURCE + XrmDatabase database = XrmGetDatabase (display->display); XrmName name_prefix[3]; XrmClass class_prefix[3]; @@ -875,5 +878,4 @@ rxvt_term::extract_resources () #endif /* NO_RESOURCES */ } -/*}}} */ /*----------------------- end-of-file (C source) -----------------------*/ -- 2.34.1