clipboard 1.3.6 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/MIT-LICENSE.txt +1 -1
- data/README.md +9 -7
- data/clipboard.gemspec +2 -1
- data/lib/clipboard/linux.rb +2 -1
- data/lib/clipboard/linux_wayland.rb +35 -0
- data/lib/clipboard/version.rb +1 -1
- data/lib/clipboard.rb +17 -11
- data/spec/clipboard_file_spec.rb +1 -1
- data/spec/clipboard_spec.rb +5 -4
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1176250dac08a0b34135139cae0057d85980a5db1b64f56b5c89fd4745d176e2
|
4
|
+
data.tar.gz: b55213775852ec00ffa7d58a8e97b8e3b31530067e02e6604885873e44a6424e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317ce477428ad9390f5ea8dff8afac8fbd23633210bc94de5a4f5db55982681e1a6fa7c4eca2c2204ca4d46238a707ec1a5516076fa456556ad0ec0bd1b7221e
|
7
|
+
data.tar.gz: f7245a4588ba5fecfd2974f970b6849807fe488acc321b54d546c993900c95487b2be5c0bf50230ba617fa3aac15097ffc912050fdbe1cf2983be41321b6b976
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.4.1
|
4
|
+
* Always use plaintext mimetype for wl-clipboard
|
5
|
+
* Do not include newline when pasting from wl-clipboard
|
6
|
+
* Internal: Let ClipboardLoadError inherit from StandardError, not Exception
|
7
|
+
|
8
|
+
## 1.4.0
|
9
|
+
* Add Wayland support via `wl-copy`, patch by @cramt
|
10
|
+
* Only silence clipboard warnings when $VERBOSE is nil
|
11
|
+
|
3
12
|
## 1.3.6
|
4
13
|
* Fix Windows implementation (so it works on more recent Windows), patch by @P3t3rU5
|
5
14
|
|
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
Lets you access the clipboard from everywhere. Currently supported platforms:
|
4
4
|
|
5
|
-
- Linux
|
5
|
+
- Linux (X11)
|
6
|
+
- Linux (Wayland)
|
6
7
|
- MacOS
|
7
8
|
- Windows
|
8
9
|
- Cygwin (POSIX environment for Windows)
|
@@ -10,9 +11,9 @@ Lets you access the clipboard from everywhere. Currently supported platforms:
|
|
10
11
|
- Gtk+ (Cross Platform Widget Toolkit)
|
11
12
|
- Java (on JRuby)
|
12
13
|
|
13
|
-
Supported Rubies: **3.
|
14
|
+
Supported Rubies: **3.3**, **3.2**, **3.1**, **3.0**
|
14
15
|
|
15
|
-
Unsupported, but might still work: **2.
|
16
|
+
Unsupported, but might still work: **2.X**
|
16
17
|
|
17
18
|
## Usage
|
18
19
|
|
@@ -29,7 +30,7 @@ gem "clipboard"
|
|
29
30
|
gem "ffi", :platforms => [:mswin, :mingw] # Required by Clipboard on Windows
|
30
31
|
```
|
31
32
|
|
32
|
-
- **Important note for Linux** users: The clipboard requires the *xsel* or the *xclip* command-line program. On debian and ubuntu, *xsel* can be installed with: `sudo apt-get install xsel`
|
33
|
+
- **Important note for Linux** users: The clipboard requires the *xsel* or the *xclip* command-line program (X11), or the *wl-copy* / *wl-paste* command-line programs (Wayland). On debian and ubuntu, *xsel* can be installed with: `sudo apt-get install xsel` and *wl-copy* / *wl-paste* with `sudo apt-get install wl-clipboard`.
|
33
34
|
|
34
35
|
## Clipboard Implementations
|
35
36
|
|
@@ -70,7 +71,7 @@ passing it as an argument. The default is *:clipboard*, other options are *:prim
|
|
70
71
|
|
71
72
|
### Windows: Encoding Info
|
72
73
|
|
73
|
-
Windows uses [UTF-16LE](https://en.wikipedia.org/wiki/UTF-16) as its default encoding, so pasted strings will always come in UTF-16. You can then manually convert them to your desired encoding, for example, UTF-8, using the [String#encode](
|
74
|
+
Windows uses [UTF-16LE](https://en.wikipedia.org/wiki/UTF-16) as its default encoding, so pasted strings will always come in UTF-16. You can then manually convert them to your desired encoding, for example, UTF-8, using the [String#encode](https://rubyapi.org/o/string#method-i-encode) method:
|
74
75
|
|
75
76
|
```ruby
|
76
77
|
Clipboard.paste.encode('UTF-8')
|
@@ -90,9 +91,10 @@ Without any arguments, it will just paste the contents of the clipboard.
|
|
90
91
|
|
91
92
|
This is a list of nice-to-have features - feel free to open a PR or let me know if you want to work on one of these:
|
92
93
|
|
93
|
-
-
|
94
|
+
- Native support for clipboard on X11 or Wayland
|
95
|
+
- Support more platforms
|
94
96
|
- Support clipboard meta data
|
95
97
|
|
96
98
|
## MIT
|
97
99
|
|
98
|
-
Copyright (c) 2010-
|
100
|
+
Copyright (c) 2010-2024 Jan Lelis <https://janlelis.com> released under the MIT license. Contributions by and thanks to [Michael Grosser and all the other contributors!](https://github.com/janlelis/clipboard/graphs/contributors)
|
data/clipboard.gemspec
CHANGED
@@ -12,8 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = "Access to the clipboard on Linux, MacOS, Windows, and Cygwin: Clipboard.copy, Clipboard.paste, Clipboard.clear"
|
13
13
|
s.homepage = "https://github.com/janlelis/clipboard"
|
14
14
|
s.license = "MIT"
|
15
|
+
s.metadata = { "rubygems_mfa_required" => "true" }
|
15
16
|
s.requirements = [
|
16
|
-
"Linux: You need xclip
|
17
|
+
"Linux: You need xclip / xsel (X11) or wl-clipboard (Wayland)",
|
17
18
|
"Windows: You need the ffi gem",
|
18
19
|
]
|
19
20
|
s.files = Dir.glob(%w[{lib,spec}/**/*.rb [A-Z]*.txt [A-Z]*.md]) + %w{clipboard.gemspec}
|
data/lib/clipboard/linux.rb
CHANGED
@@ -27,7 +27,8 @@ module Clipboard
|
|
27
27
|
}.freeze
|
28
28
|
else
|
29
29
|
raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program xclip or xsel\n" \
|
30
|
-
"On debian/ubuntu, you can install it with: sudo apt-get install xsel"
|
30
|
+
"On debian/ubuntu, you can install it with: sudo apt-get install xsel\n" \
|
31
|
+
"If your system is Wayland-based, please install wl-clipboard"
|
31
32
|
end
|
32
33
|
|
33
34
|
def paste(which = nil)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "utils"
|
4
|
+
|
5
|
+
module Clipboard
|
6
|
+
module LinuxWayland
|
7
|
+
extend self
|
8
|
+
|
9
|
+
TEST_COMMAND = "wl-copy"
|
10
|
+
WRITE_COMMAND = "wl-copy --type text/plain"
|
11
|
+
READ_COMMAND = "wl-paste --type text/plain --no-newline"
|
12
|
+
|
13
|
+
if !Utils.executable_installed?(TEST_COMMAND)
|
14
|
+
raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program wl-copy\n" \
|
15
|
+
"Please install it or try a different implementation"
|
16
|
+
end
|
17
|
+
|
18
|
+
def paste(might_select_primary_clipboard = nil)
|
19
|
+
if might_select_primary_clipboard == "primary"
|
20
|
+
`#{READ_COMMAND} --primary`
|
21
|
+
else
|
22
|
+
`#{READ_COMMAND}`
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy(data)
|
27
|
+
Utils.popen WRITE_COMMAND, data
|
28
|
+
paste
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear
|
32
|
+
`#{WRITE_COMMAND} --clear`
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/clipboard/version.rb
CHANGED
data/lib/clipboard.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rbconfig'
|
4
|
-
|
4
|
+
|
5
|
+
require_relative 'clipboard/version'
|
6
|
+
require_relative 'clipboard/utils'
|
5
7
|
|
6
8
|
module Clipboard
|
7
9
|
extend self
|
8
10
|
|
9
|
-
class ClipboardLoadError <
|
11
|
+
class ClipboardLoadError < StandardError
|
10
12
|
end
|
11
13
|
|
12
14
|
unless defined? Ocra # see gh#9
|
13
|
-
autoload :Linux,
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
autoload :
|
15
|
+
autoload :Linux, 'clipboard/linux'
|
16
|
+
autoload :LinuxWayland, 'clipboard/linux_wayland'
|
17
|
+
autoload :Mac, 'clipboard/mac'
|
18
|
+
autoload :Java, 'clipboard/java'
|
19
|
+
autoload :Cygwin, 'clipboard/cygwin'
|
20
|
+
autoload :Wsl, 'clipboard/wsl'
|
21
|
+
autoload :Gtk, 'clipboard/gtk'
|
19
22
|
end
|
20
23
|
autoload :Windows, 'clipboard/windows'
|
21
24
|
autoload :File, 'clipboard/file'
|
@@ -29,20 +32,23 @@ module Clipboard
|
|
29
32
|
when /mswin|mingw/ then :Windows
|
30
33
|
when /cygwin/ then :Cygwin
|
31
34
|
else
|
32
|
-
raise ClipboardLoadError, "Your OS(#{ RbConfig::CONFIG['host_os'] }) is not supported
|
35
|
+
raise ClipboardLoadError, "Your OS(#{ RbConfig::CONFIG['host_os'] }) is not supported"
|
33
36
|
end
|
34
37
|
|
35
|
-
# Running additional check to detect if running in Microsoft WSL
|
38
|
+
# Running additional check to detect if running in Microsoft WSL or Wayland
|
36
39
|
if os == :Linux
|
37
40
|
require "etc"
|
38
41
|
if Etc.respond_to?(:uname) && Etc.uname[:release] =~ /Microsoft/ # uname was added in ruby 2.2
|
39
42
|
os = :Wsl
|
43
|
+
# Only choose Wayland implementation if wl-copy is found, since xclip / xsel *might* work
|
44
|
+
elsif ENV["XDG_SESSION_TYPE"] == "wayland" && Utils.executable_installed?("wl-copy")
|
45
|
+
os = :LinuxWayland
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
49
|
@implementation = Clipboard.const_get(os)
|
44
50
|
rescue ClipboardLoadError => e
|
45
|
-
$stderr.puts e.message
|
51
|
+
$stderr.puts "#{e.message}\nUsing file-based (fake) clipboard" unless $VERBOSE == nil
|
46
52
|
@implementation = Clipboard::File
|
47
53
|
end
|
48
54
|
|
data/spec/clipboard_file_spec.rb
CHANGED
data/spec/clipboard_spec.rb
CHANGED
@@ -74,12 +74,13 @@ describe Clipboard do
|
|
74
74
|
|
75
75
|
describe :implementation do
|
76
76
|
before do
|
77
|
-
$VERBOSE =
|
77
|
+
$VERBOSE = false
|
78
78
|
Clipboard.implementation = nil
|
79
79
|
end
|
80
80
|
|
81
81
|
it "does not warn on normal detection" do
|
82
|
-
if system('which xclip >/dev/null 2>&1') || system('which xsel >/dev/null 2>&1')
|
82
|
+
if ( ENV["XDG_SESSION_TYPE"] != "wayland" && (system('which xclip >/dev/null 2>&1') || system('which xsel >/dev/null 2>&1') ) ) ||
|
83
|
+
( ENV["XDG_SESSION_TYPE"] == "wayland" && system('which wl-copy >/dev/null 2>&1') )
|
83
84
|
expect( $stderr ).not_to receive(:puts)
|
84
85
|
end
|
85
86
|
Clipboard.implementation
|
@@ -91,8 +92,8 @@ describe Clipboard do
|
|
91
92
|
expect( Clipboard.implementation ).to eq Clipboard::File
|
92
93
|
end
|
93
94
|
|
94
|
-
it "does not warn when $VERBOSE is
|
95
|
-
$VERBOSE =
|
95
|
+
it "does not warn when $VERBOSE is nil" do
|
96
|
+
$VERBOSE = nil
|
96
97
|
RbConfig::CONFIG['host_os'] = 'Fooo OS'
|
97
98
|
expect( $stderr ).not_to receive(:puts)
|
98
99
|
Clipboard.implementation
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clipboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/clipboard/gtk.rb
|
58
58
|
- lib/clipboard/java.rb
|
59
59
|
- lib/clipboard/linux.rb
|
60
|
+
- lib/clipboard/linux_wayland.rb
|
60
61
|
- lib/clipboard/mac.rb
|
61
62
|
- lib/clipboard/utils.rb
|
62
63
|
- lib/clipboard/version.rb
|
@@ -68,7 +69,8 @@ files:
|
|
68
69
|
homepage: https://github.com/janlelis/clipboard
|
69
70
|
licenses:
|
70
71
|
- MIT
|
71
|
-
metadata:
|
72
|
+
metadata:
|
73
|
+
rubygems_mfa_required: 'true'
|
72
74
|
post_install_message:
|
73
75
|
rdoc_options: []
|
74
76
|
require_paths:
|
@@ -84,9 +86,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
86
|
- !ruby/object:Gem::Version
|
85
87
|
version: '0'
|
86
88
|
requirements:
|
87
|
-
- 'Linux: You need xclip
|
89
|
+
- 'Linux: You need xclip / xsel (X11) or wl-clipboard (Wayland)'
|
88
90
|
- 'Windows: You need the ffi gem'
|
89
|
-
rubygems_version: 3.
|
91
|
+
rubygems_version: 3.5.3
|
90
92
|
signing_key:
|
91
93
|
specification_version: 4
|
92
94
|
summary: Access to the clipboard on Linux, MacOS, Windows, and Cygwin.
|