--- rxvt-unicode/src/urxvt.pm 2006/01/08 22:58:13 1.58 +++ rxvt-unicode/src/urxvt.pm 2006/01/09 19:25:57 1.65 @@ -60,9 +60,14 @@ =item option-popup (enabled by default) -Binds a popup menu to Ctrl-Button3 that lets you toggle (some) options at +Binds a popup menu to Ctrl-Button2 that lets you toggle (some) options at runtime. +=item selection-popup (enabled by default) + +Binds a popup menu to Ctrl-Button3 that lets you convert the selection +text into various other formats/action. + =item digital-clock Displays a digital clock using the built-in overlay. @@ -202,10 +207,6 @@ $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_tty_activity $term *NYI* - -Called whenever the program(s) running in the urxvt window send output. - =item on_osc_seq $term, $string Called whenever the B command sequence (OSC = @@ -334,6 +335,12 @@ Using this function has the advantage that its output ends up in the correct place, e.g. on stderr of the connecting urxvtc client. +=item $is_safe = urxvt::safe + +Returns true when it is safe to do potentially unsafe things, such as +evaluating perl code specified by the user. This is true when urxvt was +started setuid or setgid. + =item $time = urxvt::NOW Returns the "current time" (as per the event loop). @@ -425,6 +432,11 @@ unless $msg =~ /\n$/; urxvt::warn ($msg); }; + + delete $ENV{IFS}; + delete $ENV{CDPATH}; + delete $ENV{BASH_ENV}; + $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin"; } my @hook_count; @@ -467,14 +479,12 @@ open my $fh, "<:raw", $path or die "$path: $!"; - my $source = "package $pkg; use strict; use utf8;\n" + my $source = untaint "package $pkg; use strict; use utf8;\n" . "use base urxvt::term::proxy::;\n" . "#line 1 \"$path\"\n{\n" . (do { local $/; <$fh> }) . "\n};\n1"; - $source =~ /(.*)/s and $source = $1; # untaint - eval $source or die "$path: $@"; $pkg @@ -495,7 +505,7 @@ for (map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2) { if ($_ eq "default") { - $want_ext{$_}++ for qw(selection option-popup); + $want_ext{$_}++ for qw(selection option-popup selection-popup); } elsif (/^-(.*)$/) { delete $want_ext{$1}; } else { @@ -1094,7 +1104,6 @@ ) } -=item ($row, $col) = $line->coord_of ($offset) =item $text = $term->special_encode $string Converts a perl string into the special encoding used by rxvt-unicode, @@ -1106,6 +1115,34 @@ Converts rxvt-unicodes text reprsentation into a perl string. See C<< $term->ROW_t >> for details. +=item $success = $term->grab_button ($button, $modifiermask) + +Registers a synchronous button grab. See the XGrabButton manpage. + +=item $success = $term->grab ($eventtime[, $sync]) + +Calls XGrabPointer and XGrabKeyboard in asynchronous (default) or +synchronous (C<$sync> is true). Also remembers the grab timestampe. + +=item $term->allow_events_async + +Calls XAllowEvents with AsyncBoth for the most recent grab. + +=item $term->allow_events_sync + +Calls XAllowEvents with SyncBoth for the most recent grab. + +=item $term->allow_events_replay + +Calls XAllowEvents with both ReplayPointer and ReplayKeyboard for the most +recent grab. + +=item $term->ungrab + +Calls XUngrab 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. + =back =cut @@ -1138,7 +1175,7 @@ $self->add_item ({ rend => { normal => "\x1b[0;30;47m", hover => "\x1b[0;30;47m", active => "\x1b[0;30;47m" }, text => "", - render => sub { $sep x $urxvt::TERM->ncol }, + render => sub { $sep x $self->{term}->ncol }, activate => sub { }, }); } @@ -1156,7 +1193,7 @@ sub add_button { my ($self, $text, $cb) = @_; - $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb}); + $self->add_item ({ type => "button", text => $text, activate => $cb}); } sub add_toggle { @@ -1178,8 +1215,11 @@ local $urxvt::popup::self = $self; + local $ENV{LC_ALL} = $self->{term}->locale; + urxvt->new ("--perl-lib" => "", "--perl-ext-common" => "", "-pty-fd" => -1, "-sl" => 0, "-b" => 0, "--transient-for" => $self->{term}->parent, + "-display" => $self->{term}->display_id, "-pe" => "urxvt-popup") or die "unable to create popup window\n"; }