Closed mokun closed 5 years ago
Ctrl-C / Ctrl-V should work out of the box. I have no issues with copy and paste on my Linux system.
I think I know part of the problem. I doubt you have played the game. In the game CTRL+C is defined to show list of countries as can be seen in the screenshot I'm sharing below.
@mokun One workaround is have some other key combo for list of countries.
Some other workarounds could be to have it behave like a traditional x-term-emulator which means having a full-fledged Title bar support which means having things like
Edit and Help at the very least . Help showing the version of beryx/text-io and Edit having Select All, Copy and Paste using either keyboard or/and mouse.
Another could be just be having a mouse support with right-click menu which has Select All, Copy and Paste.
The easiest though would be to drop CTRL+C from list of countries and perhaps have something like
CTRL+Shift+C for list of list of countries perhaps ?
Even though then the problem of Selecting arbitary rows and columns of text is still not solved. I did try to use the mouse to mark from where I want text to be selected till where it should select but was unsuccessful. I have to confess I have been spoiled in being able to use this functionality by almost any x-term-emulator.
The game has a console front-end and hence we need the functionality to be able to copy partial text and show the inconsistencies therein so they can be ironed out by @mokun
I do hope I have been able to make myself clear.
Please let me know if I have been unable to articulate the issue if unclear somewhere and will try to be more clear.
You can register handlers for the copy and paste actions. Try something like this:
terminal.registerHandler("control INSERT", t -> {
t.getTextPane().copy();
return new ReadHandlerData(ReadInterruptionStrategy.Action.CONTINUE);
});
terminal.registerHandler("shift INSERT", t -> {
t.getTextPane().paste();
return new ReadHandlerData(ReadInterruptionStrategy.Action.CONTINUE);
});
Replace "control INSERT" and "shift INSERT" with the key combinations you prefer.
Could there be something for arbitary text selections via mouse or should I/we put up a new bug instead to address that ?
This will append the text selected by mouse to the input:
terminal.registerHandler("shift INSERT", t -> {
String selectedText = t.getTextPane().getSelectedText();
if(selectedText != null) {
t.getTextPane().setCaretPosition(t.getDocument().getLength());
t.appendToInput(selectedText, false);
}
return new ReadHandlerData(ReadInterruptionStrategy.Action.CONTINUE);
});
@siordache ,
The Ctrl-C and Ctrl-V works by default in Windows at least.
Appreciate with your snippet of codes above. Now I can change it to whatever I need.
Other than keyboard, can we have a right-click popup menu for doing copy and paste with a mouse ?
@siordache ,
The Ctrl-C and Ctrl-V works by default in Windows at least.
Appreciate with your snippet of codes above. Now I can change it to whatever I need.
Other than keyboard, can we have a right-click popup menu for doing copy and paste with a mouse ?
It will surely help us if we can have mouse support as well. Would making a right-click menu with options for Copy and Paste be too much work ?
The SwingTextTerminal exposes its frame and textPane, so you can add context menus or main menus to them using plain Swing programming. I recommend putting these changes in a subclass of SwingTextTerminal, as shown here.
@siordache , thanks much for the implementation ! I'm closing this thread now.
Hi,
Is there a method to call to enable the ability to copy and paste text from a Swing terminal in linux ?
Thx!