Comments (9)
Well I do find it surprising because I didn't know that.
And what you are saying is that the example in the README might not actually set the contents of the clipboard b/c the context goes out of scope right afterwards??
extern crate copypasta;
use copypasta::{ClipboardContext, ClipboardProvider};
fn main() {
let mut ctx = ClipboardContext::new().unwrap();
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".to_owned()).unwrap();
}
from copypasta.
That's just how clipboards work and have always worked on Linux. It shouldn't come as a surprise?
from copypasta.
Okay, I still think there should be an explanation of why calling get_contents
after set_contents
is necessary because as an API that is not intuitive.
from copypasta.
Does the application keep running or are you terminating? On Linux the application delivers the clipboard content when the paste request is made, so if you quit before then there will be nothing to answer that request.
You might also want to look into clipboard managers, which act as an intermediate.
from copypasta.
The application keeps running, but the clipboard context does go out of scope right after I call set_contents
. Does that matter?
from copypasta.
Yeah, the clipboard needs to stay alive. Should be pretty simple to test though.
from copypasta.
Is this documented anywhere in copypasta
that the clipboard context must remain in scope in order to guarantee that the contents will actually be set?
from copypasta.
I've opened #50 to make our examples more consistent. That should make it less likely for people to get confused.
from copypasta.
It's not necessary. The only thing that is necessary is that the clipboard context needs to still be alive when it is retrieved. Which should be intuitive for Linux users imo.
from copypasta.
Related Issues (20)
- Migrate from Travis CI to github actions
- function or associated item not found in `dyn ClipboardProvider` HOT 1
- Segfault in smithay-clipboard -- dep needs to be bumped to 0.6.2 or later HOT 1
- Is Wayland supported by default, or is additional logic required for this? HOT 1
- Feature Request: Android support via Termux. HOT 1
- Using xcb which is unmaintained and has multiple soundness issues HOT 2
- docs bug HOT 4
- Paste functionality uses old, cached values HOT 11
- Android support HOT 6
- request to feature gate backends HOT 3
- Add support for non-text clipboard content HOT 12
- Please document Wayland usage HOT 2
- Proposal to change the x11 clipboard implementation HOT 4
- Improve/more specific error if TTY/CI? HOT 2
- Element not found on Win11 HOT 1
- Listening for changes MacOS HOT 4
- Reading the clipboard is surprisingly slow HOT 6
- Clipboard not working on wayland HOT 5
- clipboard-win dependency is outdated HOT 1
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 copypasta.