… | |
… | |
165 | overlays or changes. |
165 | overlays or changes. |
166 | |
166 | |
167 | =item selection-pastebin |
167 | =item selection-pastebin |
168 | |
168 | |
169 | This is a little rarely useful extension that Uploads the selection as |
169 | This is a little rarely useful extension that Uploads the selection as |
170 | textfile to a remote site (or does other things). |
170 | textfile to a remote site (or does other things). (The implementation is |
|
|
171 | not currently secure for use in a multiuser environment as it writes to |
|
|
172 | F</tmp> directly.). |
171 | |
173 | |
172 | It listens to the C<selection-pastebin:remote-pastebin> keyboard command, |
174 | It listens to the C<selection-pastebin:remote-pastebin> keyboard command, |
173 | i.e. |
175 | i.e. |
174 | |
176 | |
175 | URxvt.keysym.C-M-e: perl:selection-pastebin:remote-pastebin |
177 | URxvt.keysym.C-M-e: perl:selection-pastebin:remote-pastebin |
… | |
… | |
593 | =back |
595 | =back |
594 | |
596 | |
595 | =cut |
597 | =cut |
596 | |
598 | |
597 | BEGIN { |
599 | BEGIN { |
598 | urxvt->bootstrap; |
|
|
599 | |
|
|
600 | # overwrite perl's warn |
600 | # overwrite perl's warn |
601 | *CORE::GLOBAL::warn = sub { |
601 | *CORE::GLOBAL::warn = sub { |
602 | my $msg = join "", @_; |
602 | my $msg = join "", @_; |
603 | $msg .= "\n" |
603 | $msg .= "\n" |
604 | unless $msg =~ /\n$/; |
604 | unless $msg =~ /\n$/; |
… | |
… | |
617 | sub verbose { |
617 | sub verbose { |
618 | my ($level, $msg) = @_; |
618 | my ($level, $msg) = @_; |
619 | warn "$msg\n" if $level <= $verbosity; |
619 | warn "$msg\n" if $level <= $verbosity; |
620 | } |
620 | } |
621 | |
621 | |
622 | my $extension_pkg = "extension0000"; |
|
|
623 | my %extension_pkg; |
622 | my %extension_pkg; |
624 | |
623 | |
625 | # load a single script into its own package, once only |
624 | # load a single script into its own package, once only |
626 | sub extension_package($) { |
625 | sub extension_package($) { |
627 | my ($path) = @_; |
626 | my ($path) = @_; |
628 | |
627 | |
|
|
628 | no strict 'refs'; |
|
|
629 | |
629 | $extension_pkg{$path} ||= do { |
630 | $extension_pkg{$path} ||= do { |
630 | my $pkg = "urxvt::" . ($extension_pkg++); |
631 | $path =~ /([^\/\\]+)$/; |
|
|
632 | my $pkg = $1; |
|
|
633 | $pkg =~ s/[^[:word:]]/_/g; |
|
|
634 | $pkg = "urxvt::ext::$pkg"; |
631 | |
635 | |
632 | verbose 3, "loading extension '$path' into package '$pkg'"; |
636 | verbose 3, "loading extension '$path' into package '$pkg'"; |
633 | |
637 | |
634 | open my $fh, "<:raw", $path |
638 | open my $fh, "<:raw", $path |
635 | or die "$path: $!"; |
639 | or die "$path: $!"; |
636 | |
640 | |
|
|
641 | @{"$pkg\::ISA"} = urxvt::term::extension::; |
|
|
642 | |
637 | my $source = |
643 | my $source = |
638 | "package $pkg; use strict; use utf8;\n" |
644 | "package $pkg; use strict; use utf8;\n" |
639 | . "use base urxvt::term::extension::;\n" |
|
|
640 | . "#line 1 \"$path\"\n{\n" |
645 | . "#line 1 \"$path\"\n{\n" |
641 | . (do { local $/; <$fh> }) |
646 | . (do { local $/; <$fh> }) |
642 | . "\n};\n1"; |
647 | . "\n};\n1"; |
643 | |
648 | |
644 | eval $source |
649 | eval $source |