1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 18:35:32 +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 0e02e7fcf3
commit bae5a00d0f
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) - [433751] Add option to enable VT100 line wrapping mode
* Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers * Anton Leherbauer (Wind River) - [434294] Incorrect handling of function keys with modifiers
* Martin Oberhuber (Wind River) - [434294] Add Mac bindings with COMMAND * 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; package org.eclipse.tm.internal.terminal.emulator;
@ -242,10 +243,13 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
} }
private void copy(int clipboardType) { private void copy(int clipboardType) {
Object[] data = new Object[] { getSelection() }; String selection = getSelection();
if (selection.length() > 0) {
Object[] data = new Object[] { selection };
Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
fClipboard.setContents(data, types, clipboardType); fClipboard.setContents(data, types, clipboardType);
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste() * @see org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl#paste()

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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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) - [196465] Resizing Terminal changes Scroller location
* Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour * Anton Leherbauer (Wind River) - [324608] Terminal has strange scrolling behaviour
* Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically * 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; package org.eclipse.tm.internal.terminal.textcanvas;
@ -331,10 +332,13 @@ public class TextCanvas extends GridCanvas {
return fCellCanvasModel.getSelectedText(); return fCellCanvasModel.getSelectedText();
} }
public void copy() { public void copy() {
String selectionText = getSelectionText();
if (selectionText != null && selectionText.length() > 0) {
Clipboard clipboard = new Clipboard(getDisplay()); Clipboard clipboard = new Clipboard(getDisplay());
clipboard.setContents(new Object[] { getSelectionText() }, new Transfer[] { TextTransfer.getInstance() }); clipboard.setContents(new Object[] { selectionText }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose(); clipboard.dispose();
} }
}
public void selectAll() { public void selectAll() {
fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth()); fCellCanvasModel.setSelection(0, fCellCanvasModel.getTerminalText().getHeight(), 0, fCellCanvasModel.getTerminalText().getWidth());
fCellCanvasModel.setSelectionAnchor(new Point(0,0)); fCellCanvasModel.setSelectionAnchor(new Point(0,0));