Code Monkey home page Code Monkey logo

Comments (9)

dumblob avatar dumblob commented on May 21, 2024

My observation:

  1. the X11 Nuklear backend uses just X PRIMARY selection
  2. X11 PRIMARY & SECONDARY selections needs the process with data being copied from to run during pasting in another process
  3. X11 CLIPBOARD is not implemented by the X11 Nuklear backend
  4. X11 CLIPBOARD doesn't need the originating process since the moment of copying
  5. X11 doesn't offer any synchronization between any of PRIMARY, SECONDARY, and CLIPBOARD
  6. most X11 graphical environments (KDE, Gnome, ...) do support handling of either PRIMARY or CLIPBOARD and sometimes even both
  7. xterm (and other X11 native apps having no dependencies on bigger frameworks like Qt/GTK/...) uses PRIMARY
  8. most Qt/GTK/... apps use CLIPBOARD

There are tools like xsel and many others offering synchronization of these selection buffers and handling of their content in general.

If you were not aware of the above, could you retest with this new knowledge?

I myself hate this distinction between several selection buffers, so I synchronize them all using 3 instances of autocutsel and thus can use any app and paste into arbitrary another app. There are though people using multiple content records e.g. in CLIPBOARD, so this taste varies a lot I'd say.

from nuklear.

JetStarBlues avatar JetStarBlues commented on May 21, 2024

Thank you for the reply!

How is the PRIMARY clipboard supposed to be used? I am more familiar with the windows style of using CTRL+C and CTRL+V to copy and paste (as per the gdi demo). From what I am reading online, it seems that to use the PRIMARY clipboard, you select the text to copy, and middle click to paste:

For X11-based systems (ie. Linux and most other UNIX-like systems) there are two clipboards which are independent of each other:

PRIMARY - This is copy-on-select, and can be pasted with the middle mouse button.
CLIPBOARD - This is copied with (usually) ^C, and pasted with ^V (It's like MS Windows).

I opened xedit (the x11-apps version), and successfully copied and pasted text within xedit using this middle mouse button approach. However, when I select text from the nuklear textbox, and then attempt to paste it into xedit by clicking the middle mouse button nothing happens. Similarly the other way around, when I select text from xedit, and attempt to paste it into the nuklear textbox by clicking the middle mouse button, nothing happens...

It seems that NK_KEY_COPY and NK_KEY_PASTE have been associated with the CTRL+C and CTRL+V keys (see these lines). Whereas the only reference to the middle mouse button NK_BUTTON_MIDDLE in the file (nuklear_xlib.h), is the generic handler (see this line). So I am not sure how the middle mouse button is associated with pasting in the nuklear demo... Or how just selecting text is associated with copying...

Edit:
I also tried using CTRL+V in nuklear after selecting text in xedit but no luck this way either. The thought process here was, selecting text in xedit places it in the PRIMARY clipboard. And CTRL+V on nuklear would trigger the paste handler...

Edit2:
I also tried all the above steps mentioned for xedit, using the default Ubuntu terminal (i.e. copying and pasting text on the terminal using the middle mouse button interface) and Vim just in case xedit was not a good test candidate. It still failed... Copy/paste works between apps, but not between nuklear.

from nuklear.

dumblob avatar dumblob commented on May 21, 2024

Thanks for thorough testing you did. As you experienced, PRIMARY is not necessarily handled (e.g. pasted) just by MMB. Let's try to dig deeper.

  1. Does copy&paste work within your Nuklear app itself in the same text widget instance?
  2. Does copy&paste work within your Nuklear app itself among different text widget instances?

from nuklear.

JetStarBlues avatar JetStarBlues commented on May 21, 2024

Hi
It does not work within the same text widget, or between text widgets. (Using the variety of copy/paste approaches (CTRL+C/V, middle mouse button, combos) described above).

from nuklear.

dumblob avatar dumblob commented on May 21, 2024

Could you pleasy simulate the two cases from #17 (comment) fully programatically (i.e. just calling the appropriate functions one after another instead of waiting for mouse input etc.)?

from nuklear.

JetStarBlues avatar JetStarBlues commented on May 21, 2024

Hi
My understanding of how Nuklear works isn't good enough at the moment to do so. I can't find any documentation regarding copy/paste let alone how to do it programatically. The copy/paste seems to be handled by nk_do_edit (link) but I'm not sure how to combine that with the nk_edit_string that generates the textbox (link)...

from nuklear.

dumblob avatar dumblob commented on May 21, 2024

Please post your full code you're using to test the copy & paste behavior (use e.g. pastebin), so that we have a specific starting point.

from nuklear.

JetStarBlues avatar JetStarBlues commented on May 21, 2024

I am using the "overview.c" example that comes with the source code (see picture above).

nk_label(ctx, "Box:", NK_TEXT_LEFT);

from nuklear.

dumblob avatar dumblob commented on May 21, 2024

A minimal example how to use X11 clipboard/selection capabilities is on https://gist.github.com/vurtun/1c57d1e9e2ee169b90209325e38f0cb7 - might be interesting to compare with the current Nuklear backend implementation.

from nuklear.

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.