… | |
… | |
38 | if (my $pid = open my $fh, "|-:utf8", $self->{store_cmd}) { |
38 | if (my $pid = open my $fh, "|-:utf8", $self->{store_cmd}) { |
39 | fcntl $fh, &Fcntl::F_SETFL, &Fcntl::O_NONBLOCK; |
39 | fcntl $fh, &Fcntl::F_SETFL, &Fcntl::O_NONBLOCK; |
40 | $self->{iow} = urxvt::iow |
40 | $self->{iow} = urxvt::iow |
41 | ->new |
41 | ->new |
42 | ->fd (fileno $fh) |
42 | ->fd (fileno $fh) |
43 | ->events (urxvt::EVENT_WRITE) |
43 | ->events (urxvt::EV_WRITE) |
44 | ->start |
44 | ->start |
45 | ->cb (sub { |
45 | ->cb (sub { |
46 | if (my $len = syswrite $fh, $txt) { |
46 | if (my $len = syswrite $fh, $txt) { |
47 | substr $txt, 0, $len, ""; |
47 | substr $txt, 0, $len, ""; |
48 | $self->msg ((length $txt) . " chars to go..."); |
48 | $self->msg ((length $txt) . " chars to go..."); |
… | |
… | |
63 | if (my $pid = open my $fh, "-|:utf8", $self->{fetch_cmd}) { |
63 | if (my $pid = open my $fh, "-|:utf8", $self->{fetch_cmd}) { |
64 | fcntl $fh, &Fcntl::F_SETFL, &Fcntl::O_NONBLOCK; |
64 | fcntl $fh, &Fcntl::F_SETFL, &Fcntl::O_NONBLOCK; |
65 | $self->{iow} = urxvt::iow |
65 | $self->{iow} = urxvt::iow |
66 | ->new |
66 | ->new |
67 | ->fd (fileno $fh) |
67 | ->fd (fileno $fh) |
68 | ->events (urxvt::EVENT_READ) |
68 | ->events (urxvt::EV_READ) |
69 | ->start |
69 | ->start |
70 | ->cb (sub { |
70 | ->cb (sub { |
71 | if (my $len = sysread $fh, $txt, 8192, length $txt) { |
71 | if (my $len = sysread $fh, $txt, 8192, length $txt) { |
72 | $self->msg ((length $txt) . " chars read..."); |
72 | $self->msg ((length $txt) . " chars read..."); |
73 | } else { |
73 | } else { |
74 | delete $self->{iow}; |
74 | delete $self->{iow}; |
75 | $self->selection_clear; |
75 | $self->selection_clear; |
76 | $self->selection ($txt); |
76 | $self->selection ($txt); |
77 | $self->selection_grab (urxvt::CurrentTime); |
77 | $self->selection_grab (urxvt::CurrentTime); |
78 | close $fh; |
|
|
79 | my $status = $? >> 8; |
|
|
80 | $self->msg ("selection fetched (status $status)"); |
78 | $self->msg ("selection fetched"); |
81 | } |
79 | } |
82 | }); |
80 | }); |
83 | } |
81 | } |
84 | } |
82 | } |
85 | |
83 | |
… | |
… | |
100 | }; |
98 | }; |
101 | |
99 | |
102 | () |
100 | () |
103 | } |
101 | } |
104 | |
102 | |
105 | sub on_user_command { |
|
|
106 | my ($self, $cmd) = @_; |
|
|
107 | |
103 | |
108 | if ($cmd eq "selection-pastebin:remote-pastebin") { |
|
|
109 | $self->upload_paste; |
|
|
110 | } |
|
|
111 | |
|
|
112 | () |
|
|
113 | } |
|
|
114 | |
|
|