repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 7a7a3379be6f1afdda8657a417fd18b712b39ea0: path_to: revision_to:
commit 7a7a3379be6f1afdda8657a417fd18b712b39ea0 Author: Robin RedekerDate: Tue Jan 17 16:53:47 2006 +0000 moved pastebin code from selection to src/perl/selection-pastebin and corrected documentation diff --git a/Changes b/Changes
--- a/Changes
+++ b/Changes
@@ -13,13 +13,13 @@ WISH: just for fun, do shade and tint with XRender.
WISH: support tex fonts
9.0
+ - new script: perl/selection-pastebin
- improved security of setuid/setgid operation, which is now
encouraged, by moving privileged operations into a separate
process and permanently dropping privileges within the
terminal. This makes it possible to remove security checks from
the perl code and gives a much safer feeling when urxvt needs to
run with special privileges.
- - implemented perl:selection:remote-pastebin command in perl/selection
- use the scrollback buffer even when the scroll region doesn't
span the whole screen, as long as it starts at row 0.
- swap the environment in some more cases. This hopefully fixes
diff --git a/src/perl/selection b/src/perl/selection
--- a/src/perl/selection
+++ b/src/perl/selection
@@ -1,60 +1,4 @@
#! perl
-use Digest::MD5 qw/md5_hex/;
-
-my $timers = {};
-my $pastebin_cmd;
-my $pastebin_url;
-
-sub on_start {
- my ($self) = @_;
- $pastebin_cmd = $self->x_resource ("selection-pastebin-cmd")
- or "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
-
- $pastebin_url = $self->x_resource ("selection-pastebin-url")
- or "http://www.ta-sa.org/files/txt/";
- ();
-}
-
-sub upload_paste {
- my ($self) = @_;
-
- my $txt = $self->selection;
- my $filename = md5_hex ($txt) . ".txt";
-
- my $tmpfile = "/tmp/$filename";
-
- my $msg = "uploaded $filename";
-
- if (open my $o, ">" . $tmpfile) {
- print $o $txt;
- close $o;
- } else {
- $msg = "couldn't write $tmpfile: $!";
- }
-
- my $cmd = $pastebin_cmd;
- $cmd =~ s/%/$tmpfile/;
-
- if (system ($cmd) == 0) {
-
- my $url = $pastebin_url;
- $url =~ s/%/$filename/;
-
- $self->selection ($url);
- } else {
- $msg = "couldn't upload, '$cmd' failed";
- }
-
- my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0);
- $ov->set (0, 0, $msg);
-
- $timers->{t1} =
- urxvt::timer
- ->new
- ->start ((int urxvt::NOW) + 5) # make sure we update "on" the second
- ->interval (1)
- ->cb (sub { delete $timers->{ov}; delete $timers->{t1}; });
-}
sub on_keyboard_command {
my ($self, $cmd) = @_;
@@ -62,9 +6,6 @@ sub on_keyboard_command {
$cmd eq "selection:rot13"
and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection);
- $cmd eq "selection:remote-pastebin"
- and upload_paste ($self);
-
()
}
diff --git a/src/perl/selection-pastebin b/src/perl/selection-pastebin
new file mode 100644
index 0000000000000000000000000000000000000000..aea0258879ef979da9f10ecd69d4c7b5a62cc1bb
--- /dev/null
+++ b/src/perl/selection-pastebin
@@ -0,0 +1,69 @@
+#! perl
+use Digest::MD5 qw/md5_hex/;
+
+my $timers = {};
+my $pastebin_cmd;
+my $pastebin_url;
+
+sub on_start {
+ my ($self) = @_;
+ $pastebin_cmd =
+ $self->x_resource ("selection-pastebin-cmd")
+ or "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
+
+ $pastebin_url =
+ $self->x_resource ("selection-pastebin-url")
+ or "http://www.ta-sa.org/files/txt/";
+ ();
+}
+
+sub upload_paste {
+ my ($self) = @_;
+
+
+ my $txt = $self->selection;
+ my $filename = md5_hex ($txt) . ".txt";
+
+ my $tmpfile = "/tmp/$filename";
+
+ my $msg = "uploaded $filename";
+
+ if (open my $o, ">" . $tmpfile) {
+ print $o $txt;
+ close $o;
+ } else {
+ $msg = "couldn't write $tmpfile: $!";
+ }
+
+ my $cmd = $pastebin_cmd;
+ $cmd =~ s/%/$tmpfile/;
+
+ if (system ($cmd) == 0) {
+ my $url = $pastebin_url;
+ $url =~ s/%/$filename/;
+
+ $self->selection ($url);
+ } else {
+ $msg = "couldn't upload, '$cmd' failed";
+ }
+
+ my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0);
+ $ov->set (0, 0, $msg);
+
+ $timers->{t1} =
+ urxvt::timer
+ ->new
+ ->start ((int urxvt::NOW) + 5) # make sure we update "on" the second
+ ->interval (1)
+ ->cb (sub { delete $timers->{ov}; delete $timers->{t1}; });
+}
+
+sub on_keyboard_command {
+ my ($self, $cmd) = @_;
+
+ $cmd eq "selection-pastebin:remote-pastebin"
+ and upload_paste ($self);
+
+ ()
+}
+
diff --git a/src/urxvt.pm b/src/urxvt.pm
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -78,23 +78,6 @@ Rot-13 the selection when activated. Used via keyboard trigger:
URxvt.keysym.C-M-r: perl:selection:rot13
-=item remote-pastebin
-
-Upload the selection as textfile to a remote site.
-
- URxvt.keysym.C-M-e: perl:selection:remote-pastebin
-
-To set the command to upload the file set this resource:
-
- URxvt.selection-pastebin-cmd: rsync -apP % ruth:/var/www/www.ta-sa.org/files/txt/.
-
-The % is the placeholder for the textfile. The name of the textfile is the hex encoded
-md5 sum of the selection.
-After an successful upload the selection will be replaced by the following url
-(the % is the placeholder for the filename):
-
- URxvt.selection-pastebin-url: http://www.ta-sa.org/files/txt/%
-
=back
=item option-popup (enabled by default)
@@ -181,6 +164,23 @@ 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 selection-pastebin
+
+Uploads the selection as textfile to a remote site.
+
+ URxvt.keysym.C-M-e: perl:selection-pastebin:remote-pastebin
+
+To set the command to upload the file set this resource:
+
+ URxvt.selection-pastebin-cmd: rsync -apP % ruth:/var/www/www.ta-sa.org/files/txt/.
+
+The % is the placeholder for the textfile. The name of the textfile is the hex encoded
+md5 sum of the selection.
+After an successful upload the selection will be replaced by the following url
+(the % is the placeholder for the filename):
+
+ URxvt.selection-pastebin-url: http://www.ta-sa.org/files/txt/%
+
=back
=head1 API DOCUMENTATION
-----END OF PAGE-----