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
#! 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: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);
-
()
}
--- /dev/null
+#! 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);
+
+ ()
+}
+
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)
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