clipboard 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +2 -0
- data/lib/clipboard/version.rb +1 -1
- data/lib/clipboard/windows.rb +6 -8
- data/spec/clipboard_spec.rb +9 -0
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
data/lib/clipboard/version.rb
CHANGED
data/lib/clipboard/windows.rb
CHANGED
@@ -35,6 +35,7 @@ module Clipboard::Windows
|
|
35
35
|
|
36
36
|
attach_function :lock, :GlobalLock, [ :long ], :pointer
|
37
37
|
attach_function :unlock, :GlobalUnlock, [ :long ], :long
|
38
|
+
attach_function :size, :GlobalSize, [ :long ], :long
|
38
39
|
attach_function :alloc, :GlobalAlloc, [ :long, :long ], :long
|
39
40
|
end
|
40
41
|
|
@@ -47,16 +48,13 @@ module Clipboard::Windows
|
|
47
48
|
pointer_to_data = Kernel32.lock( hclip )
|
48
49
|
data = ""
|
49
50
|
# Windows Unicode is ended by to null bytes, so get the whole string
|
50
|
-
|
51
|
-
|
52
|
-
data << pointer_to_data.get_bytes( current_byte, 1 )
|
53
|
-
current_byte += 1
|
54
|
-
end
|
51
|
+
size = Kernel32.size( hclip )
|
52
|
+
data << pointer_to_data.get_bytes( 0, size - 2 )
|
55
53
|
if RUBY_VERSION >= '1.9'
|
56
|
-
ret = data.
|
54
|
+
ret = data.force_encoding("UTF-16LE").encode(Encoding.default_external) # TODO catch bad encodings
|
57
55
|
else # 1.8: fallback to simple CP850 encoding
|
58
56
|
require 'iconv'
|
59
|
-
utf8 = Iconv.iconv( "UTF-8", "UTF-16LE", data
|
57
|
+
utf8 = Iconv.iconv( "UTF-8", "UTF-16LE", data)[0]
|
60
58
|
ret = Iconv.iconv( "CP850", "UTF-8", utf8)[0]
|
61
59
|
end
|
62
60
|
if data && 0 != data
|
@@ -80,7 +78,7 @@ module Clipboard::Windows
|
|
80
78
|
if ( RUBY_VERSION >= '1.9' ) && 0 != User32.open( 0 )
|
81
79
|
User32.empty( )
|
82
80
|
data = data_to_copy.encode("UTF-16LE") # TODO catch bad encodings
|
83
|
-
data << 0
|
81
|
+
data << 0
|
84
82
|
handler = Kernel32.alloc( GMEM_MOVEABLE, data.bytesize )
|
85
83
|
pointer_to_data = Kernel32.lock( handler )
|
86
84
|
pointer_to_data.put_bytes( 0, data, 0, data.bytesize )
|
data/spec/clipboard_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# Please note: cannot test, if it really accesses your platform clipboard.
|
2
3
|
|
3
4
|
require File.expand_path('spec/spec_helper')
|
@@ -18,6 +19,14 @@ describe Clipboard do
|
|
18
19
|
Clipboard.paste.should == "FOO\nBAR"
|
19
20
|
end
|
20
21
|
|
22
|
+
if RUBY_VERSION >= "1.9"
|
23
|
+
it "can copy & paste with multibyte char" do
|
24
|
+
Encoding.default_external = "utf-8"
|
25
|
+
Clipboard.copy("日本語")
|
26
|
+
Clipboard.paste.should == "日本語"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
21
30
|
it "returns data on copy" do
|
22
31
|
Clipboard.copy('xxx').should == 'xxx'
|
23
32
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clipboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jan Lelis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-04-
|
18
|
+
date: 2013-04-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|