Coder Social home page Coder Social logo

Comments (9)

AustinScola avatar AustinScola commented on August 24, 2024 2

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.

chrisduerr avatar chrisduerr commented on August 24, 2024 1

That's just how clipboards work and have always worked on Linux. It shouldn't come as a surprise?

from copypasta.

AustinScola avatar AustinScola commented on August 24, 2024 1

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.

chrisduerr avatar chrisduerr commented on August 24, 2024

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.

AustinScola avatar AustinScola commented on August 24, 2024

The application keeps running, but the clipboard context does go out of scope right after I call set_contents. Does that matter?

from copypasta.

chrisduerr avatar chrisduerr commented on August 24, 2024

Yeah, the clipboard needs to stay alive. Should be pretty simple to test though.

from copypasta.

AustinScola avatar AustinScola commented on August 24, 2024

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.

chrisduerr avatar chrisduerr commented on August 24, 2024

I've opened #50 to make our examples more consistent. That should make it less likely for people to get confused.

from copypasta.

chrisduerr avatar chrisduerr commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.