… | |
… | |
58 | |
58 | |
59 | () |
59 | () |
60 | } |
60 | } |
61 | |
61 | |
62 | sub paste { |
62 | sub paste { |
63 | my ($self) = @_; |
63 | my ($self, $escape) = @_; |
64 | |
64 | |
65 | my $str = `$self->{paste_cmd}`; |
65 | my $str = `$self->{paste_cmd}`; |
66 | if ($? == 0) { |
66 | if ($? == 0) { |
67 | $self->tt_paste($str); |
|
|
68 | } else { |
|
|
69 | print STDERR "error running '$self->{paste_cmd}': $!\n"; |
|
|
70 | } |
|
|
71 | |
|
|
72 | () |
|
|
73 | } |
|
|
74 | |
|
|
75 | sub paste_escaped { |
|
|
76 | my ($self) = @_; |
|
|
77 | |
|
|
78 | my $str = `$self->{paste_cmd}`; |
|
|
79 | if ($? == 0) { |
|
|
80 | $str =~ s/([!#\$%&\*\(\) ='"\\\|\[\]`~,<>\?])/\\\1/g; |
67 | $str =~ s/([!#\$%&\*\(\) ='"\\\|\[\]`~,<>\?])/\\\1/g |
|
|
68 | if ($escape); |
81 | $self->tt_paste($str); |
69 | $self->tt_paste($str); |
82 | } else { |
70 | } else { |
83 | print STDERR "error running '$self->{paste_cmd}': $!\n"; |
71 | print STDERR "error running '$self->{paste_cmd}': $!\n"; |
84 | } |
72 | } |
85 | |
73 | |
… | |
… | |
90 | my ($self, $cmd) = @_; |
78 | my ($self, $cmd) = @_; |
91 | |
79 | |
92 | if ($cmd eq "clipboard:copy") { |
80 | if ($cmd eq "clipboard:copy") { |
93 | $self->copy; |
81 | $self->copy; |
94 | } elsif ($cmd eq "clipboard:paste") { |
82 | } elsif ($cmd eq "clipboard:paste") { |
95 | $self->paste; |
83 | $self->paste (0); |
96 | } elsif ($cmd eq "clipboard:paste_escaped") { |
84 | } elsif ($cmd eq "clipboard:paste_escaped") { |
97 | $self->paste_escaped; |
85 | $self->paste (1); |
98 | } |
86 | } |
99 | |
87 | |
100 | () |
88 | () |
101 | } |
89 | } |
102 | |
90 | |