ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/selection-pastebin
(Generate patch)

Comparing rxvt-unicode/src/perl/selection-pastebin (file contents):
Revision 1.3 by root, Tue Jan 17 17:01:54 2006 UTC vs.
Revision 1.5 by root, Wed Jan 18 10:11:03 2006 UTC

1#! perl 1#! perl
2 2
3my $timers = {}; 3my $timers = {};
4my $pastebin_cmd; 4my $pastebin_cmd;
5my $pastebin_url; 5my $pastebin_url;
6
7sub on_start {
8 my ($self) = @_;
9 $pastebin_cmd =
10 $self->x_resource ("selection-pastebin.cmd")
11 or "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
12
13 $pastebin_url =
14 $self->x_resource ("selection-pastebin.url")
15 or "http://www.ta-sa.org/files/txt/";
16
17 ()
18}
19 6
20sub upload_paste { 7sub upload_paste {
21 my ($self) = @_; 8 my ($self) = @_;
22 9
23 require Digest::MD5; 10 require Digest::MD5;
46 $self->selection ($url); 33 $self->selection ($url);
47 } else { 34 } else {
48 $msg = "couldn't upload, '$cmd' failed"; 35 $msg = "couldn't upload, '$cmd' failed";
49 } 36 }
50 37
38 unlink $tmpfile;
39
51 my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0); 40 my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0);
52 $ov->set (0, 0, $msg); 41 $ov->set (0, 0, $msg);
53 42
54 $timers->{t1} = 43 $timers->{t1} =
55 urxvt::timer 44 urxvt::timer
57 ->start ((int urxvt::NOW) + 5) # make sure we update "on" the second 46 ->start ((int urxvt::NOW) + 5) # make sure we update "on" the second
58 ->interval (1) 47 ->interval (1)
59 ->cb (sub { delete $timers->{ov}; delete $timers->{t1}; }); 48 ->cb (sub { delete $timers->{ov}; delete $timers->{t1}; });
60} 49}
61 50
62sub on_keyboard_command { 51sub on_start {
63 my ($self, $cmd) = @_; 52 my ($self) = @_;
53 $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd")
54 || "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
64 55
65 $cmd eq "selection-pastebin:remote-pastebin" 56 $pastebin_url = $self->x_resource ("selection-pastebin.url")
66 and upload_paste ($self); 57 || "http://www.ta-sa.org/files/txt/%";
58
59 push @urxvt::ext::selection_popup::hook, sub {
60 ("pastebin upload" => sub { $self->upload_paste })
61 };
67 62
68 () 63 ()
69} 64}
70 65
66sub on_keyboard_command {
67 my ($self, $cmd) = @_;
68
69 if ($cmd eq "selection-pastebin:remote-pastebin") {
70 $self->upload_paste;
71 }
72
73 ()
74}
75

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines