Comments (4)
If anyone will find it interesting: On windows i cam up with simple workaround for console applications to get notified on clipboard change events properly https://github.com/DoumanAsh/clipboard-master
Basic sequence of actions:
- Add window, you can create dummy window as console application, to clipboard updates using
AddClipboardFormatListener
- Listen for
WM_CLIPBOARDUPDATE
messages(each time clipboard is changed, message is sent) - To remove yourself from listening use
RemoveClipboardFormatListener
I'm not familiar with Linux/MacOS ways to do it, but considering that Qt does it, it should be possible.
from rust-clipboard.
cdaringe's link demonstrates how to do it on MacOS (via some swift code, which can be adapted to use msg_send!).
It looks like x11-clipboard doesn't have an event loop for this feature yet, but it's probably possible to adapt the existing getter loop (i.e. from Clipboard::load), and ideally factor out some common event loop that can be used for both the getter and the notifier.
Since it's supportable on all the platforms so far, it's in-scope for the library.
As far as interface goes, does adding a function like get_change_notifier(&self) -> Receiver</* something like an enum over formats or a String */>
to the ClipboardProvider trait seem reasonable?
from rust-clipboard.
In X11 this can be implement with FixesExt, but I don't have much time. I'd be happy if someone could help.
from rust-clipboard.
@aweinstock314 By Receiver
do you mean it is going to be channel's end? It might be fine API but it would imply that thread will be started implicitly to wait for clipboard changes.
I wouldn't recommend returning content of clipboard and instead the Receiver
should be over simple enum:
enum ClipboardStateChange<T> {
NewContent,
Error(T)
As clipboard is global on windows, having option to read/write in multiple threads is a bad idea.
But I also think there should be configuration option to identify type of clipboard change.
For example user might be interested only in plain text or image.
So maybe it could be something like:
let listener = ClipboardListenerBuilder::new().listen(Event::Text).listen(Event::Image)
let clipboard_change = clipboard.enable_listener(listener);
I guess having it as both iterator or channel's receiver would be good.
P.s. for Windows I'm also thinking maybe moving into clipboard crate itself.
from rust-clipboard.
Related Issues (20)
- Handling trailing \u{0} from the [Windows] clipboard HOT 4
- Error: load selection timeout HOT 2
- Use enums instead of Box<Error> for failure HOT 8
- Is this repo still maintained? HOT 1
- Please publish 5.0 HOT 1
- Clipboard is cleared when the process exits on Linux HOT 8
- Getting Err value on provider.get_contents().unwrap() HOT 1
- Only installing xorg-dev does not fetch all dependencies HOT 4
- How to automatically output snippets to the cursor๏ผ HOT 1
- clipboard not compiling on Travis CI linux targets
- NSPasteboard#generalPasteboard returned null when called from macOS launchd Launch Daemon HOT 1
- Thank you ๐
- test failed in copr HOT 1
- Incorrect behaviour on Linux with two clipboards HOT 1
- set_contents doesnt work for me HOT 3
- Can't run example on FreeBSD HOT 2
- Security advisory: please release with upgraded `xcb` dependencies
- Please clarify maintenance status HOT 4
- Dependency issue on official docker rust image
- Shouldn't failure conditions return `Err`?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-clipboard.