macos 0.1.6 → 0.1.8
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/lib/macos/display.rb +19 -4
- data/lib/macos/keyboard.rb +1 -1
- data/lib/macos/library/core_graphics/key_code.rb +3 -0
- data/lib/macos/library/core_graphics.rb +2 -0
- data/lib/macos/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906112e5154c3bb3b289accad6e1a4d74e43bcc69056848a7300cf0f01dc3eeb
|
4
|
+
data.tar.gz: 3f2b011e2877d7880e9eed8cf75a9aeff04a63ba206bda21984466a6647e1a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09002ddfa40a57fe51bb99705f4e62b5df2467c07561bd29f9238aac5d4a9954cc4bf31567b1dbcadc91bdf6a1a65e742024cc61c2f4f4f77b1f660050e605df'
|
7
|
+
data.tar.gz: ba769566717499722b25de6b9a2f4fbdced6db31bc1de5860523ed1dcfa9189377a2d1b54e0f1e878a695c13b2002f1fb8d88b3af2b5dccc2972db18fbff3541
|
data/lib/macos/display.rb
CHANGED
@@ -7,6 +7,10 @@ module MacOS
|
|
7
7
|
class Display
|
8
8
|
Size = Struct.new(:width, :height)
|
9
9
|
|
10
|
+
# @!attr_accessor :id
|
11
|
+
# # @return [Integer]
|
12
|
+
attr_accessor :id
|
13
|
+
|
10
14
|
def self.main
|
11
15
|
id = Library::CoreGraphics.CGMainDisplayID
|
12
16
|
new(id:)
|
@@ -27,10 +31,21 @@ module MacOS
|
|
27
31
|
Size.new(width, height)
|
28
32
|
end
|
29
33
|
|
30
|
-
# @
|
31
|
-
|
32
|
-
|
34
|
+
# @retrun [Integer]
|
35
|
+
def wide
|
36
|
+
Library::CoreGraphics.CGDisplayPixelsWide(@id)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @retrun [Integer]
|
40
|
+
def high
|
41
|
+
Library::CoreGraphics.CGDisplayPixelsHigh(@id)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @yield [file]
|
45
|
+
# @yieldparam file [File]
|
46
|
+
def screenshot(&)
|
33
47
|
tempfile = Tempfile.new(["screenshot", ".png"])
|
48
|
+
|
34
49
|
image = Library::CoreGraphics.CGDisplayCreateImage(@id)
|
35
50
|
|
36
51
|
encoding = Library::CoreFoundation::ENCODING_UTF8
|
@@ -48,7 +63,7 @@ module MacOS
|
|
48
63
|
Library::CoreFoundation.CFRelease(uti)
|
49
64
|
Library::CoreFoundation.CFRelease(dest)
|
50
65
|
|
51
|
-
|
66
|
+
File.open(tempfile.path, "rb", &)
|
52
67
|
ensure
|
53
68
|
tempfile.close
|
54
69
|
tempfile.unlink
|
data/lib/macos/keyboard.rb
CHANGED
@@ -186,11 +186,14 @@ module MacOS
|
|
186
186
|
"." => KEY_CODE_PERIOD,
|
187
187
|
"/" => KEY_CODE_SLASH,
|
188
188
|
"\\" => KEY_CODE_BACKSLASH,
|
189
|
+
"space" => KEY_CODE_SPACE,
|
189
190
|
" " => KEY_CODE_SPACE,
|
190
191
|
"escape" => KEY_CODE_ESCAPE,
|
191
192
|
"backspace" => KEY_CODE_DELETE,
|
192
193
|
"delete" => KEY_CODE_DELETE,
|
193
194
|
"command" => KEY_CODE_COMMAND,
|
195
|
+
"cmd" => KEY_CODE_COMMAND,
|
196
|
+
"⌘" => KEY_CODE_COMMAND,
|
194
197
|
"option" => KEY_CODE_OPTION,
|
195
198
|
"control" => KEY_CODE_CONTROL,
|
196
199
|
"shift" => KEY_CODE_SHIFT,
|
@@ -45,6 +45,8 @@ module MacOS
|
|
45
45
|
attach_function :CGMainDisplayID, [], :CGDirectDisplayID
|
46
46
|
attach_function :CGDisplayBounds, %i[CGDirectDisplayID], CGRect.by_value
|
47
47
|
attach_function :CGDisplayCreateImage, %i[CGDirectDisplayID], :CGImageRef
|
48
|
+
attach_function :CGDisplayPixelsWide, %i[CGDirectDisplayID], :size_t
|
49
|
+
attach_function :CGDisplayPixelsHigh, %i[CGDirectDisplayID], :size_t
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
data/lib/macos/version.rb
CHANGED