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.6 by root, Wed Jan 18 10:31:37 2006 UTC vs.
Revision 1.7 by root, Wed Jan 18 10:39:20 2006 UTC

1#! perl 1#! perl
2 2
3my $timers = {};
4my $pastebin_cmd; 3my $pastebin_cmd;
5my $pastebin_url; 4my $pastebin_url;
6 5
7sub upload_paste { 6sub upload_paste {
8 my ($self) = @_; 7 my ($self) = @_;
14 13
15 my $tmpfile = "/tmp/$filename"; 14 my $tmpfile = "/tmp/$filename";
16 15
17 my $msg = "uploaded $filename"; 16 my $msg = "uploaded $filename";
18 17
19 if (open my $o, ">$tmpfile") { 18 if (open my $o, ">", $tmpfile) {
20 chmod 0644, $tmpfile; 19 chmod 0644, $tmpfile;
21 print $o $txt; 20 print $o $txt;
22 close $o; 21 close $o;
23 } else { 22 } else {
24 $msg = "couldn't write $tmpfile: $!"; 23 $msg = "couldn't write $tmpfile: $!";
36 $msg = "couldn't upload, '$cmd' failed"; 35 $msg = "couldn't upload, '$cmd' failed";
37 } 36 }
38 37
39 unlink $tmpfile; 38 unlink $tmpfile;
40 39
41 my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0); 40 my $ov = $self->overlay (-1, 0, length $msg, 1, urxvt::OVERLAY_RSTYLE, 0);
42 $ov->set (0, 0, $msg); 41 $ov->set (0, 0, $msg);
43 42
44 $timers->{t1} = 43 my $timer; $timer =
45 urxvt::timer 44 urxvt::timer
46 ->new 45 ->new
47 ->start ((int urxvt::NOW) + 5) # make sure we update "on" the second 46 ->start (urxvt::NOW + 5)
48 ->interval (1) 47 ->cb (sub {undef $timer; undef $ov; });
49 ->cb (sub { delete $timers->{ov}; delete $timers->{t1}; });
50} 48}
51 49
52sub on_start { 50sub on_start {
53 my ($self) = @_; 51 my ($self) = @_;
54 $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd") 52 $pastebin_cmd = $self->x_resource ("selection-pastebin.cmd")
55 || "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/"; 53 || "rcp -p % ruth:/var/www/www.ta-sa.org/files/txt/";
56 54
57 $pastebin_url = $self->x_resource ("selection-pastebin.url") 55 $pastebin_url = $self->x_resource ("selection-pastebin.url")
58 || "http://www.ta-sa.org/files/txt/%"; 56 || "http://www.ta-sa.org/files/txt/%";
59 57
60 push @urxvt::ext::selection_popup::hook, sub { 58 push @urxvt::ext::selection_popup::hook, sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines