diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index f99ab594b89..e20f0fe1d01 100644 --- a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -24,6 +24,7 @@ * Martin Oberhuber (Wind River) - [204796] Terminal should allow setting the encoding to use * Michael Scharf (Wind River) - [237398] Terminal get Invalid Thread Access when the title is set * Martin Oberhuber (Wind River) - [240745] Pressing Ctrl+F1 in the Terminal should bring up context help + * Michael Scharf (Wind River) - [240098] The cursor should not blink when the terminal is disconnected *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -951,6 +952,22 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC public void setState(TerminalState state) { fState=state; fTerminalListener.setState(state); + // enable the (blinking) cursor if the terminal is connected + runInDisplayThread(new Runnable() { + public void run() { + if(fCtlText!=null && !fCtlText.isDisposed()) + fCtlText.setCursorEnabled(isConnected()); + }}); + } + /** + * @param runnable run in display thread + */ + private void runInDisplayThread(Runnable runnable) { + if(Display.findDisplay(Thread.currentThread())!=null) + runnable.run(); + else if(PlatformUI.isWorkbenchRunning()) + PlatformUI.getWorkbench().getDisplay().syncExec(runnable); + // else should not happen and we ignore it... } public String getSettingsSummary() { diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index f11f8925341..349a189d0af 100644 --- a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -7,6 +7,7 @@ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation + * Michael Scharf (Wind River) - [240098] The cursor should not blink when the terminal is disconnected *******************************************************************************/ package org.eclipse.tm.internal.terminal.textcanvas; @@ -41,6 +42,7 @@ public class TextCanvas extends GridCanvas { private ResizeListener fResizeListener; private int fMinColumns=20; private int fMinLines=4; + private boolean fCursorEnabled; /** * Create a new CellCanvas with the given SWT style bits. * (SWT.H_SCROLL and SWT.V_SCROLL are automatically added). @@ -65,9 +67,10 @@ public class TextCanvas extends GridCanvas { scrollToEnd(); } }); + // let the cursor blink if the text canvas gets the focus... addFocusListener(new FocusListener(){ public void focusGained(FocusEvent e) { - fCellCanvasModel.setCursorEnabled(true); + fCellCanvasModel.setCursorEnabled(fCursorEnabled); } public void focusLost(FocusEvent e) { fCellCanvasModel.setCursorEnabled(false); @@ -305,5 +308,23 @@ public class TextCanvas extends GridCanvas { redraw(); } + /** + * @return true if the cursor is enabled (blinking). By default the cursor is not enabled. + */ + public boolean isCursorEnabled() { + return fCursorEnabled; + } + + /** + * @param enabled enabling means that the cursor blinks + */ + public void setCursorEnabled(boolean enabled) { + if(enabled!=fCursorEnabled) { + fCursorEnabled=enabled; + fCellCanvasModel.setCursorEnabled(fCursorEnabled); + } + + } + }