Closed lively-ops closed 4 months ago
@lively-ops I wanted to add this as well, but for now I don't have an idea how to achieve it.
Any suggestions?
Electron's clipboard APIs seems to come from this file https://github.com/electron/electron/blob/main/shell/common/api/electron_api_clipboard.cc
But I am unable to find the depdency files.
Will look into this when I got time.
I think we will have to use winapi and cocoa crate for macOS and Windows and x11 or wayland libraries for linux.
For cross-platform support we can use conditional compilation to include platform-specific code.
For Windows, found these in winapi crate: https://docs.rs/winapi/latest/winapi/um/winuser/fn.SetClipboardData.html https://docs.rs/winapi/latest/winapi/shared/wtypes/struct.userCLIPFORMAT.html https://docs.rs/winapi/latest/winapi/um/winuser/fn.SetClipboardData.html https://docs.rs/winapi/latest/winapi/um/winuser/fn.RegisterClipboardFormatW.html https://docs.rs/winapi/latest/winapi/um/winuser/fn.RegisterClipboardFormatA.html
Reference for Windows API: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerclipboardformatw
For MacOS:
https://docs.rs/cocoa/latest/cocoa/appkit/enum.NSPasteboardWritingOptions.html
For Linux:
https://docs.rs/x11/2.3.1/x11/xlib/struct.XSelectionEvent.html#structfield.selection (X11) https://docs.rs/wayland-client/0.29.0/wayland_client/protocol/wl_data_device/enum.Request.html#variant.SetSelection (Wayland)
I will work on this. Just got clipboard files working.
Electron's clipboard APIs seems to come from this file https://github.com/electron/electron/blob/main/shell/common/api/electron_api_clipboard.cc
But I am unable to find the depdency files.
Will look into this when I got time.
The API of electron is called chromium at the bottom level.
https://source.chromium.org/chromium/chromium/src/+/main:ui/base/clipboard/clipboard_mac.mm;l=276
I recently planned to use rust to write a low-level library similar to the Electron clipboard API, which is related to the low-level system API calls mentioned above.
To be honest, the arboard library is not particularly well written, and no one is maintaining it. I am going to write one myself.
To be honest, the arboard library is not particularly well written, and no one is maintaining it. I am going to write one myself.
Thanks! Let me know when you write it, I am happy to change the clipboard dependency.
@HuakunShen I have already built the library, but it is still under development. macOS has been developed, and I am currently developing Windows and Linux. Can you please take a look at my API first? I estimate that I will complete it in about a month, and I hope that listen to other people's opinions
@ChurchTao Great, I will take a look. Thanks! I also sent you an email (gmail).
HTML and RTF supported in v0.6.0 with clipboard-rs.
Thank you for the awesome plugin. It would be perfect if you could add formatted text/rtf format as well.