From: root Date: Thu, 19 Jan 2006 16:22:12 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=12d2764331b25426da02c537400218fa2237aa2e;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/src/command.C b/src/command.C index 954baf2a..bc3f6973 100644 --- a/src/command.C +++ b/src/command.C @@ -466,7 +466,7 @@ rxvt_term::lookup_key (XKeyEvent &ev) { /* normal XTerm key bindings */ case XK_Insert: /* Shift+Insert = paste mouse selection */ - selection_request (ev.time, 0, 0); + selection_request (ev.time); return; #if TODO /* rxvt extras */ @@ -2157,9 +2157,14 @@ rxvt_term::button_release (XButtonEvent &ev) case Button3: selection_make (ev.time); break; + case Button2: - selection_request (ev.time, ev.x, ev.y); + if (IN_RANGE_EXC (ev.x, 0, width) + && IN_RANGE_EXC (ev.y, 0, height)) // inside window? + selection_request (ev.time); + break; + #ifdef MOUSE_WHEEL case Button4: case Button5: diff --git a/src/perl/selection-pastebin b/src/perl/selection-pastebin index fa34b73c..13ecf03a 100644 --- a/src/perl/selection-pastebin +++ b/src/perl/selection-pastebin @@ -49,19 +49,20 @@ sub upload_paste { sub on_start { my ($self) = @_; + $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd") || "rcp -p % ruth:/var/www/www.ta-sa.org/files/txt/"; $pastebin_url = $self->x_resource ("selection-pastebin.url") || "http://www.ta-sa.org/files/txt/%"; + push @{ $self->{term}{selection_popup_hook} }, sub { + ("pastebin upload" => sub { $self->upload_paste }) + }; + () } -push @urxvt::ext::selection_popup::hook, sub { - ("pastebin upload" => sub { $self->upload_paste }) -}; - sub on_keyboard_command { my ($self, $cmd) = @_; diff --git a/src/perl/selection-popup b/src/perl/selection-popup index 82e87d11..d5db95dc 100644 --- a/src/perl/selection-popup +++ b/src/perl/selection-popup @@ -21,8 +21,6 @@ sub on_start { () } -our @hook; - sub on_button_press { my ($self, $event) = @_; @@ -73,7 +71,7 @@ sub on_button_press { /^(http|ftp|telnet|irc|news):\// and $add_button->("run $self->{browser}" => sub { $self->exec_async ($self->{browser}, $_) }); - for my $hook (@hook) { + for my $hook (@{ $self->{term}{selection_popup_hook} || [] }) { if (my ($title, $cb) = $hook->($popup)) { $add_button->($title, $cb); } diff --git a/src/rxvt.h b/src/rxvt.h index 4640b511..85885f75 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1469,7 +1469,7 @@ struct rxvt_term : zero_initialized, rxvt_vars { void selection_check (int check_more); void selection_paste (Window win, Atom prop, bool delete_prop); void selection_property (Window win, Atom prop); - void selection_request (Time tm, int x, int y); + void selection_request (Time tm); int selection_request_other (Atom target, int selnum); void selection_clear (); void selection_make (Time tm); diff --git a/src/screen.C b/src/screen.C index 2b107068..9d53ad54 100644 --- a/src/screen.C +++ b/src/screen.C @@ -2802,11 +2802,8 @@ rxvt_term::selection_property (Window win, Atom prop) * EXT: button 2 release */ void -rxvt_term::selection_request (Time tm, int x, int y) +rxvt_term::selection_request (Time tm) { - if (x < 0 || x >= width || y < 0 || y >= height) - return; /* outside window */ - if (selection.text) { /* internal selection */ char *str = rxvt_wcstombs (selection.text, selection.len); diff --git a/src/urxvt.pm b/src/urxvt.pm index bdbf6ca4..7497db4b 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -91,8 +91,9 @@ Binds a popup menu to Ctrl-Button3 that lets you convert the selection text into various other formats/action (such as uri unescaping, perl evalution, web-browser starting etc.), depending on content. -Other extensions can extend this popup menu by pushing a code reference onto -C<@urxvt::ext::selection_popup::hook>, that is called whenever the popup is displayed. +Other extensions can extend this popup menu by pushing a code reference +onto C<@{ $term->{selection_popup_hook} }>, that is called whenever the +popup is 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. @@ -104,14 +105,11 @@ The following will add an entry C that transforms all Cs in the selection to Cs, but only if the selection currently contains any Cs: - push urxvt::ext::selection_popup::hook, sub { + push @{ $self->{term}{selection_popup_hook} }, sub { /a/ ? ("a to be" => sub { s/a/b/g } : () }; -Don't run it in a hook, otherwise the menu will grow and grow. Instead put -it at the toplevel of your extension. - =item searchable-scrollback (enabled by default) Adds regex search functionality to the scrollback buffer, triggered