mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-27 02:45:32 +02:00
bug 240098: [terminal] The cursor should not blink when the terminal is disconnected
https://bugs.eclipse.org/bugs/show_bug.cgi?id=240098
This commit is contained in:
parent
86a2ff6c0d
commit
6a5e1a00b2
2 changed files with 39 additions and 1 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue