Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clipboard with an image errors (windows) #47913

Open
MarcMush opened this issue Dec 16, 2022 · 5 comments
Open

clipboard with an image errors (windows) #47913

MarcMush opened this issue Dec 16, 2022 · 5 comments
Labels
system:windows Affects only Windows

Comments

@MarcMush
Copy link
Contributor

#46981 still happens, not when the clipboard is empty, but when there is an image in the clipboard

to reproduce, copy an image (outside Julia), then type clipboard() in the Julia terminal:

PS C:\Users\Marc> julia +1.7 --startup-file no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.3 (2022-05-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> clipboard()
""

julia>
PS C:\Users\Marc> julia +alpha --startup-file no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-alpha1 (2022-11-15)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> clipboard()
ERROR: SystemError: GetClipboardData: L’opération a réussi.
Stacktrace:
 [1] windowserror(p::Symbol, code::UInt32; extrainfo::Nothing)
   @ Base .\error.jl:191
 [2] windowserror(p::Symbol, code::UInt32)
   @ Base .\error.jl:191
 [3] cleanup
   @ C:\Users\Marc\.julia\juliaup\julia-1.9.0-alpha1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\InteractiveUtils\src\clipboard.jl:118 [inlined]
 [4] clipboard()
   @ InteractiveUtils C:\Users\Marc\.julia\juliaup\julia-1.9.0-alpha1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\InteractiveUtils\src\clipboard.jl:125
 [5] top-level scope
   @ REPL[1]:1

the error doesn't happen in 1.7, but it does happen in 1.8.3 (where I believe #47311 was merged) and 1.9-alpha

Note that in 1.7, it appeared as an empty string, even though there is actually an image in the clipboard. 1.8.3 or 1.9 doesn't error with an empty string

Also note that ironically, the error message "L’opération a réussi" means "The operation succeeded" in French (my system language)

@brenhinkeller brenhinkeller added the system:windows Affects only Windows label Dec 18, 2022
@StefanKarpinski
Copy link
Member

I guess the question is what should this do?

@aviks
Copy link
Member

aviks commented Dec 21, 2022

In Windows 11, English, the error I see is, for the record, ERROR: SystemError: GetClipboardData: Element not found.

I'd probably expect an empty string in these situations. This is what happens if I copy and image, and try to paste it in Notepad, for example, which only supports textual content.

@MarcMush
Copy link
Contributor Author

I think returning an empty string makes sense, and it is also consistent with the 1.7 and earlier behaviour

@inkydragon
Copy link
Member

We could first check if the contents of the clipboard can be converted to text, and if not, return the empty string.

  • IsClipboardFormatAvailable
    Perhaps a whitelist could be used:
    • CF_UNICODETEXT: Unicode text format.
    • CF_TEXT: Use this format for ANSI text.
    • Maybe CF_OEMTEXT: Text format containing characters in the OEM character set.

Sample Code: Using the Clipboard: Pasting Information from the Clipboard

@sefffal
Copy link

sefffal commented Dec 26, 2022

It would be amazing if the clipboard function could be extended by libraries somehow.
I would love to be able paste images into a Matrix{RGB}. This might vary too much by platform though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

6 participants