Go Down

Topic: X11 paste in IDE (Read 5 times) previous topic - next topic

Nick Gammon

 This is a minor bug.

If you don't mind my saying. This isn't a bug. It's a feature request.

With all respect to people who run Linux --- of which I am one --- most Mac/Windows users don't expect this behaviour.

Nick Gammon

I'm pretty new with Arduino ...

The IDE allows for an external editor. In what way does this not address your problem with copy/paste?

Paul Stoffregen

most Mac/Windows users don't expect this behaviour.

I would never try to emulate the X11 style on a platform where users don't expect it.  I only want to make Arduino properly integrate with X11, when actually running on Linux.

Paul Stoffregen

I've been looking into this a bit more....

The places where X11 "selection" copy works are due to having the support built in to Java's default GUI widgets.  The places where it doesn't work are where Arduino implements its own... mainly just the edit.  The bad news is there is NOT any already-working code Java within Arduino's IDE than can simply be copied to make X11 selection/clipboard work properly in the places where is currently fails.  It may seem intuitive that Arduino must already contain the proper code since it works in some places, but that is simply not the case.

I did get some partial results by modifying the FocusHandler class in JeditTextArea.java.  Specifically this:

Code: [Select]

    public void focusLost(FocusEvent evt)
      //System.out.println("JEditTextArea: focusLost");
      focusedComponent = null;
      Clipboard unixclipboard = getToolkit().getSystemSelection();
      if (unixclipboard != null) {
        String selection = getSelectedText();
        if (selection != null) {
          unixclipboard.setContents(new StringSelection(selection), null);

This is far from perfect.  First, it doesn't work for copying within Arduino itself, but it does allow you to select something in Arduino and then middle-click in another non-Arduino window to paste it.  This also has a major shortcoming where it overwrites the selection from any other window if something is currently selected in Arduino and Arduino gets and loses focus even momentarily (perhaps while moving the mouse over it in focus follow cursor window management mode).

Of course, this only exports data from Arduino and does nothing to allow middle-click within Arduino.

I still do not know how to set up a listener for the actual event of the current selection changing by mouse or keyboard actions.  That really is necessary to truly make this work the way it should.

But maybe sharing this less-than-ideal code might help, in the unlikely case someone (other than me) actually works on this?

Paul Stoffregen

Update: I got it working!!!!  ]:D

Testing now.  Patch coming soon.....

Go Up