diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2021-01-03 00:55:29 +0100 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2021-01-03 16:21:34 +0100 |
| commit | 4a3d2a8ddaf4e546df360656bc54b2947bdb890b (patch) | |
| tree | f571511e0b74fbd7e78f7e10966a8d6d5d400241 /overlays/urxvt/52-osc.pl | |
| parent | 3b5ab82fa714a0d483a7b90d60f9f7c857646e33 (diff) | |
| download | nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar.gz nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar.bz2 nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar.xz nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.zip | |
gkleen@sif: import
Diffstat (limited to 'overlays/urxvt/52-osc.pl')
| -rw-r--r-- | overlays/urxvt/52-osc.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/overlays/urxvt/52-osc.pl b/overlays/urxvt/52-osc.pl new file mode 100644 index 00000000..3292e8c4 --- /dev/null +++ b/overlays/urxvt/52-osc.pl | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #! perl | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | 52-osc - Implement OSC 32 ; Interact with X11 clipboard | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | urxvt -pe 52-osc | ||
| 10 | |||
| 11 | =head1 DESCRIPTION | ||
| 12 | |||
| 13 | This extension implements OSC 52 for interacting with system clipboard | ||
| 14 | |||
| 15 | Most code stolen from: | ||
| 16 | http://ailin.tucana.uberspace.de/static/nei/*/Code/urxvt/ | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | use MIME::Base64; | ||
| 21 | use Encode; | ||
| 22 | |||
| 23 | sub on_osc_seq { | ||
| 24 | my ($term, $op, $args) = @_; | ||
| 25 | return () unless $op eq 52; | ||
| 26 | |||
| 27 | my ($clip, $data) = split ';', $args, 2; | ||
| 28 | if ($data eq '?') { | ||
| 29 | # my $data_free = $term->selection(); | ||
| 30 | # Encode::_utf8_off($data_free); # XXX | ||
| 31 | # $term->tt_write("\e]52;$clip;".encode_base64($data_free, '')."\a"); | ||
| 32 | } | ||
| 33 | else { | ||
| 34 | my $data_decoded = decode_base64($data); | ||
| 35 | Encode::_utf8_on($data_decoded); # XXX | ||
| 36 | $term->selection($data_decoded, $clip =~ /c|^$/); | ||
| 37 | $term->selection_grab(urxvt::CurrentTime, $clip =~ /c|^$/); | ||
| 38 | } | ||
| 39 | |||
| 40 | () | ||
| 41 | } | ||
