-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from hyrodium/feature/mac
Add support for mac
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ jobs: | |
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
- macos-latest | ||
arch: | ||
- x64 | ||
include: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
_osascript() -> Matrix{<:Colorant} | ||
Paste an image from clipboard using osascript | ||
""" | ||
function _osascript() | ||
mktempdir() do dir | ||
# Define path | ||
path_png = joinpath(dir, "clipboard.png") | ||
|
||
# Compose command & run | ||
cmd = Cmd(["osascript", "-e", "write (the clipboard as «class PNGf») to (open for access \"$(path_png)\" with write permission)"]) | ||
run(cmd) | ||
|
||
# Paste from clipboard | ||
if isfile(path_png) | ||
img = load(path_png) | ||
return img | ||
else | ||
error("No image in clipboard") | ||
end | ||
end | ||
end | ||
|
||
""" | ||
_osascript(img::Matrix{<:Colorant}) | ||
Copy an image to clipboard using osascript | ||
""" | ||
function _osascript(img::Matrix{<:Colorant}) | ||
mktempdir() do dir | ||
# Define path | ||
path_png = joinpath(dir, "clipboard.png") | ||
|
||
# Save image | ||
save(path_png, img) | ||
|
||
# Compose command & run | ||
cmd = Cmd(["osascript", "-e", "set the clipboard to (read \"$(path_png)\" as «class PNGf»)"]) | ||
run(cmd) | ||
end | ||
end |