1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Terminal: Bug 434749 UnhandledEventLoopException when copying to clipboard while the selection is empty

The text copied to the clipboard must not be empty.

Change-Id: I4202b3d95419a4395af608a9d5ad30f957c3eff4
Signed-off-by: Anton Leherbauer <anton.leherbauer@windriver.com>
This commit is contained in:
Anton Leherbauer 2014-05-13 16:25:53 +02:00
parent 289dc00391
commit bd06c9ab9b
2 changed files with 15 additions and 7 deletions

View file

@ -35,6 +35,7 @@
* Anton Leherbauer (Wind River) - [433751] Add option to enable VT100 line wrapping mode
* Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers
* Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND
* Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty
*******************************************************************************/
package org.eclipse.tm.internal.terminal.emulator;
@ -242,9 +243,12 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
}
private void copy(int clipboardType) {
Object[] data = new Object[] { getSelection() };
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
fClipboard.setContents(data, types, clipboardType);
String selection = getSelection();
if (selection.length() > 0) {
Object[] data = new Object[] { selection };
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
fClipboard.setContents(data, types, clipboardType);
}
}
/* (non-Javadoc)

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -16,6 +16,7 @@
* Anton Leherbauer (Wind River) - [196465] Resizing Terminal changes Scroller location
* Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour
* Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically
* Anton Leherbauer (Wind River) - [434749] UnhandledEventLoopException when copying to clipboard while the selection is empty
*******************************************************************************/
package org.eclipse.tm.internal.terminal.textcanvas;
@ -331,9 +332,12 @@ public class TextCanvas extends GridCanvas {
return fCellCanvasModel.getSelectedText();
}
public void copy() {
Clipboard clipboard = new Clipboard(getDisplay());
clipboard.setContents(new Object[] { getSelectionText() }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose();
String selectionText = getSelectionText();
if (selectionText != null && selectionText.length() > 0) {
Clipboard clipboard = new Clipboard(getDisplay());
clipboard.setContents(new Object[] { selectionText }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
}
public void selectAll() {
fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth());