… | |
… | |
11 | my $txt = $self->selection; |
11 | my $txt = $self->selection; |
12 | my $filename = Digest::MD5::md5_hex ($txt) . ".txt"; |
12 | my $filename = Digest::MD5::md5_hex ($txt) . ".txt"; |
13 | |
13 | |
14 | my $tmpfile = "/tmp/$filename"; |
14 | my $tmpfile = "/tmp/$filename"; |
15 | |
15 | |
16 | my $msg = "uploaded $filename"; |
16 | my $msg = "uploaded as $filename"; |
17 | |
17 | |
18 | if (open my $o, ">", $tmpfile) { |
18 | if (open my $o, ">:utf-8", $tmpfile) { |
19 | chmod 0644, $tmpfile; |
19 | chmod 0644, $tmpfile; |
20 | print $o $txt; |
20 | print $o $txt; |
21 | close $o; |
21 | close $o; |
22 | } else { |
22 | } else { |
23 | $msg = "couldn't write $tmpfile: $!"; |
23 | $msg = "couldn't write $tmpfile: $!"; |
… | |
… | |
42 | |
42 | |
43 | my $timer; $timer = |
43 | my $timer; $timer = |
44 | urxvt::timer |
44 | urxvt::timer |
45 | ->new |
45 | ->new |
46 | ->after (5) |
46 | ->after (5) |
47 | ->cb (sub {undef $timer; undef $ov; }); |
47 | ->cb (sub { undef $timer; undef $ov; }); |
48 | } |
48 | } |
49 | |
49 | |
50 | sub on_start { |
50 | sub on_start { |
51 | my ($self) = @_; |
51 | my ($self) = @_; |
|
|
52 | |
52 | $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd") |
53 | $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd") |
53 | || "rcp -p % ruth:/var/www/www.ta-sa.org/files/txt/"; |
54 | || "rcp -p % ruth:/var/www/www.ta-sa.org/files/txt/"; |
54 | |
55 | |
55 | $pastebin_url = $self->x_resource ("selection-pastebin.url") |
56 | $pastebin_url = $self->x_resource ("selection-pastebin.url") |
56 | || "http://www.ta-sa.org/files/txt/%"; |
57 | || "http://www.ta-sa.org/files/txt/%"; |
57 | |
58 | |
|
|
59 | push @{ $self->{term}{selection_popup_hook} }, sub { |
|
|
60 | ("pastebin upload" => sub { $self->upload_paste }) |
|
|
61 | }; |
|
|
62 | |
58 | () |
63 | () |
59 | } |
64 | } |
60 | |
|
|
61 | push @urxvt::ext::selection_popup::hook, sub { |
|
|
62 | ("pastebin upload" => sub { $self->upload_paste }) |
|
|
63 | }; |
|
|
64 | |
65 | |
65 | sub on_keyboard_command { |
66 | sub on_keyboard_command { |
66 | my ($self, $cmd) = @_; |
67 | my ($self, $cmd) = @_; |
67 | |
68 | |
68 | if ($cmd eq "selection-pastebin:remote-pastebin") { |
69 | if ($cmd eq "selection-pastebin:remote-pastebin") { |