mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-01 03:47:23 +03:00
Support select-paste on Linux (Paul Stoffregen)
This commit is contained in:
@ -1187,6 +1187,16 @@ public class JEditTextArea extends JComponent
|
|||||||
selectionEndLine = newEndLine;
|
selectionEndLine = newEndLine;
|
||||||
biasLeft = newBias;
|
biasLeft = newBias;
|
||||||
|
|
||||||
|
if (newStart != newEnd) {
|
||||||
|
Clipboard unixclipboard = getToolkit().getSystemSelection();
|
||||||
|
if (unixclipboard != null) {
|
||||||
|
String selection = getSelectedText();
|
||||||
|
if (selection != null) {
|
||||||
|
unixclipboard.setContents(new StringSelection(selection), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fireCaretEvent();
|
fireCaretEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,7 +1659,11 @@ public class JEditTextArea extends JComponent
|
|||||||
for(int i = 0; i < repeatCount; i++)
|
for(int i = 0; i < repeatCount; i++)
|
||||||
buf.append(selection);
|
buf.append(selection);
|
||||||
|
|
||||||
clipboard.setContents(new StringSelection(buf.toString()),null);
|
Transferable t = new StringSelection(buf.toString());
|
||||||
|
clipboard.setContents(t, null);
|
||||||
|
|
||||||
|
Clipboard unixclipboard = getToolkit().getSystemSelection();
|
||||||
|
if (unixclipboard != null) unixclipboard.setContents(t, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2206,6 +2220,25 @@ public class JEditTextArea extends JComponent
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// on Linux, middle button pastes selected text
|
||||||
|
if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
|
||||||
|
Clipboard unixclipboard = getToolkit().getSystemSelection();
|
||||||
|
if (unixclipboard != null) {
|
||||||
|
Transferable t = unixclipboard.getContents(null);
|
||||||
|
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
|
||||||
|
try {
|
||||||
|
String s = (String)t.getTransferData(DataFlavor.stringFlavor);
|
||||||
|
s = s.replace('\u00A0', ' ');
|
||||||
|
if (editable) setSelectedText(s);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println(e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int line = yToLine(evt.getY());
|
int line = yToLine(evt.getY());
|
||||||
int offset = xToOffset(line,evt.getX());
|
int offset = xToOffset(line,evt.getX());
|
||||||
int dot = getLineStartOffset(line) + offset;
|
int dot = getLineStartOffset(line) + offset;
|
||||||
|
@ -108,6 +108,8 @@ public class DiscourseFormat {
|
|||||||
// i don't care about ownership
|
// i don't care about ownership
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
|
||||||
|
if (unixclipboard != null) unixclipboard.setContents(formatted, null);
|
||||||
|
|
||||||
editor.statusNotice("Code formatted for " +
|
editor.statusNotice("Code formatted for " +
|
||||||
(html ? "HTML" : "the Arduino forum ") +
|
(html ? "HTML" : "the Arduino forum ") +
|
||||||
|
Reference in New Issue
Block a user