()
| 866 | } |
| 867 | |
| 868 | void paste() { |
| 869 | String s; |
| 870 | s = ta.getSelectedText(); |
| 871 | Clipboard clipboard = getToolkit( ). getSystemClipboard(); |
| 872 | Transferable clipData = clipboard.getContents(s); |
| 873 | try { |
| 874 | s = (String)(clipData.getTransferData(DataFlavor.stringFlavor)); |
| 875 | } catch (Exception e) { |
| 876 | s = e.toString( ); |
| 877 | } |
| 878 | int start = ta.getSelectionStart( ); |
| 879 | int end = ta.getSelectionEnd( ); |
| 880 | ta.replaceRange(s, start-offset(start), end-offset(end-2>=start?end-2:start)); |
| 881 | if (IJ.isMacOSX()) |
| 882 | ta.setCaretPosition(start+s.length()); |
| 883 | checkForCurlyQuotes = true; |
| 884 | } |
| 885 | |
| 886 | // workaround for TextArea.getCaretPosition() bug on Windows |
| 887 | private int offset(int pos) { |
no test coverage detected