mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 12:05:21 +02:00
bug 206219: [terminal] make it easy to invert the terminal colors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206219
This commit is contained in:
parent
0114f92c25
commit
51e913592d
12 changed files with 54 additions and 9 deletions
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* Michael Scharf (Wind River) - initial API and implementation
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.view;
|
package org.eclipse.tm.internal.terminal.view;
|
||||||
|
@ -22,6 +22,7 @@ public class TerminalPreferenceInitializer extends AbstractPreferenceInitializer
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
Preferences store = TerminalViewPlugin.getDefault().getPluginPreferences();
|
Preferences store = TerminalViewPlugin.getDefault().getPluginPreferences();
|
||||||
store.setDefault(TerminalPreferencePage.PREF_LIMITOUTPUT, TerminalPreferencePage.DEFAULT_LIMITOUTPUT);
|
store.setDefault(TerminalPreferencePage.PREF_LIMITOUTPUT, TerminalPreferencePage.DEFAULT_LIMITOUTPUT);
|
||||||
|
store.setDefault(TerminalPreferencePage.PREF_INVERT_COLORS, TerminalPreferencePage.DEFAULT_INVERT_COLORS);
|
||||||
store.setDefault(TerminalPreferencePage.PREF_BUFFERLINES, TerminalPreferencePage.DEFAULT_BUFFERLINES);
|
store.setDefault(TerminalPreferencePage.PREF_BUFFERLINES, TerminalPreferencePage.DEFAULT_BUFFERLINES);
|
||||||
store.setDefault(TerminalPreferencePage.PREF_TIMEOUT_SERIAL, TerminalPreferencePage.DEFAULT_TIMEOUT_SERIAL);
|
store.setDefault(TerminalPreferencePage.PREF_TIMEOUT_SERIAL, TerminalPreferencePage.DEFAULT_TIMEOUT_SERIAL);
|
||||||
store.setDefault(TerminalPreferencePage.PREF_TIMEOUT_NETWORK, TerminalPreferencePage.DEFAULT_TIMEOUT_NETWORK);
|
store.setDefault(TerminalPreferencePage.PREF_TIMEOUT_NETWORK, TerminalPreferencePage.DEFAULT_TIMEOUT_NETWORK);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* Helmut Haigermoser and Ted Williams.
|
* Helmut Haigermoser and Ted Williams.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - split into core, view and connector plugins
|
* Michael Scharf (Wind River) - split into core, view and connector plugins
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.view;
|
package org.eclipse.tm.internal.terminal.view;
|
||||||
|
@ -35,14 +35,18 @@ public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
||||||
public static final String PREF_BUFFERLINES = "TerminalPrefBufferLines"; //$NON-NLS-1$
|
public static final String PREF_BUFFERLINES = "TerminalPrefBufferLines"; //$NON-NLS-1$
|
||||||
public static final String PREF_TIMEOUT_SERIAL = "TerminalPrefTimeoutSerial"; //$NON-NLS-1$
|
public static final String PREF_TIMEOUT_SERIAL = "TerminalPrefTimeoutSerial"; //$NON-NLS-1$
|
||||||
public static final String PREF_TIMEOUT_NETWORK = "TerminalPrefTimeoutNetwork"; //$NON-NLS-1$
|
public static final String PREF_TIMEOUT_NETWORK = "TerminalPrefTimeoutNetwork"; //$NON-NLS-1$
|
||||||
|
public static final String PREF_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$
|
||||||
public static final boolean DEFAULT_LIMITOUTPUT = true;
|
public static final boolean DEFAULT_LIMITOUTPUT = true;
|
||||||
public static final int DEFAULT_BUFFERLINES = 1000;
|
public static final int DEFAULT_BUFFERLINES = 1000;
|
||||||
public static final int DEFAULT_TIMEOUT_SERIAL = 5;
|
public static final int DEFAULT_TIMEOUT_SERIAL = 5;
|
||||||
public static final int DEFAULT_TIMEOUT_NETWORK = 5;
|
public static final int DEFAULT_TIMEOUT_NETWORK = 5;
|
||||||
|
public static final boolean DEFAULT_INVERT_COLORS = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected TerminalBooleanFieldEditor fEditorLimitOutput;
|
protected TerminalBooleanFieldEditor fEditorLimitOutput;
|
||||||
|
|
||||||
|
protected BooleanFieldEditor fInvertColors;
|
||||||
|
|
||||||
protected IntegerFieldEditor fEditorBufferSize;
|
protected IntegerFieldEditor fEditorBufferSize;
|
||||||
|
|
||||||
protected IntegerFieldEditor fEditorSerialTimeout;
|
protected IntegerFieldEditor fEditorSerialTimeout;
|
||||||
|
@ -57,6 +61,7 @@ public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
||||||
Label ctlLabel;
|
Label ctlLabel;
|
||||||
boolean bEnabled;
|
boolean bEnabled;
|
||||||
|
|
||||||
|
|
||||||
ctlButton = fEditorLimitOutput.getChangeControl(getFieldEditorParent());
|
ctlButton = fEditorLimitOutput.getChangeControl(getFieldEditorParent());
|
||||||
ctlText = fEditorBufferSize.getTextControl(getFieldEditorParent());
|
ctlText = fEditorBufferSize.getTextControl(getFieldEditorParent());
|
||||||
ctlLabel = fEditorBufferSize.getLabelControl(getFieldEditorParent());
|
ctlLabel = fEditorBufferSize.getLabelControl(getFieldEditorParent());
|
||||||
|
@ -95,6 +100,9 @@ public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
||||||
setPreferenceStore(preferenceStore);
|
setPreferenceStore(preferenceStore);
|
||||||
}
|
}
|
||||||
protected void setupEditors() {
|
protected void setupEditors() {
|
||||||
|
fInvertColors = new BooleanFieldEditor(
|
||||||
|
PREF_INVERT_COLORS, ViewMessages.INVERT_COLORS,
|
||||||
|
getFieldEditorParent());
|
||||||
fEditorLimitOutput = new TerminalBooleanFieldEditor(
|
fEditorLimitOutput = new TerminalBooleanFieldEditor(
|
||||||
PREF_LIMITOUTPUT, ViewMessages.LIMITOUTPUT,
|
PREF_LIMITOUTPUT, ViewMessages.LIMITOUTPUT,
|
||||||
getFieldEditorParent());
|
getFieldEditorParent());
|
||||||
|
@ -111,6 +119,7 @@ public class TerminalPreferencePage extends FieldEditorPreferencePage implements
|
||||||
fEditorSerialTimeout.setValidRange(0, Integer.MAX_VALUE);
|
fEditorSerialTimeout.setValidRange(0, Integer.MAX_VALUE);
|
||||||
fEditorNetworkTimeout.setValidRange(0, Integer.MAX_VALUE);
|
fEditorNetworkTimeout.setValidRange(0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
addField(fInvertColors);
|
||||||
addField(fEditorLimitOutput);
|
addField(fEditorLimitOutput);
|
||||||
addField(fEditorBufferSize);
|
addField(fEditorBufferSize);
|
||||||
addField(fEditorSerialTimeout);
|
addField(fEditorSerialTimeout);
|
||||||
|
|
|
@ -125,6 +125,10 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
||||||
|| event.getProperty().equals(TerminalPreferencePage.PREF_BUFFERLINES)) {
|
|| event.getProperty().equals(TerminalPreferencePage.PREF_BUFFERLINES)) {
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
}
|
}
|
||||||
|
if(event.getProperty().equals(TerminalPreferencePage.PREF_INVERT_COLORS)) {
|
||||||
|
Preferences preferences = TerminalViewPlugin.getDefault().getPluginPreferences();
|
||||||
|
fCtlTerminal.setInvertedColors(preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public TerminalView() {
|
public TerminalView() {
|
||||||
|
@ -167,7 +171,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
||||||
if(!limitOutput)
|
if(!limitOutput)
|
||||||
bufferLineLimit=-1;
|
bufferLineLimit=-1;
|
||||||
fCtlTerminal.setBufferLineLimit(bufferLineLimit);
|
fCtlTerminal.setBufferLineLimit(bufferLineLimit);
|
||||||
|
|
||||||
}
|
}
|
||||||
// TerminalTarget interface
|
// TerminalTarget interface
|
||||||
public void setState(final TerminalState state) {
|
public void setState(final TerminalState state) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* Helmut Haigermoser and Ted Williams.
|
* Helmut Haigermoser and Ted Williams.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - split into core, view and connector plugins
|
* Michael Scharf (Wind River) - split into core, view and connector plugins
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.view;
|
package org.eclipse.tm.internal.terminal.view;
|
||||||
|
@ -30,8 +30,9 @@ public class ViewMessages extends NLS {
|
||||||
public static String CONNECTIONTYPE;
|
public static String CONNECTIONTYPE;
|
||||||
public static String VIEW_TITLE;
|
public static String VIEW_TITLE;
|
||||||
public static String VIEW_SETTINGS;
|
public static String VIEW_SETTINGS;
|
||||||
|
|
||||||
public static String LIMITOUTPUT;
|
public static String LIMITOUTPUT;
|
||||||
|
public static String INVERT_COLORS;
|
||||||
public static String BUFFERLINES;
|
public static String BUFFERLINES;
|
||||||
public static String SERIALTIMEOUT;
|
public static String SERIALTIMEOUT;
|
||||||
public static String NETWORKTIMEOUT;
|
public static String NETWORKTIMEOUT;
|
||||||
|
@ -40,7 +41,7 @@ public class ViewMessages extends NLS {
|
||||||
public static String STATE_CONNECTING;
|
public static String STATE_CONNECTING;
|
||||||
public static String STATE_OPENED;
|
public static String STATE_OPENED;
|
||||||
public static String STATE_CLOSED;
|
public static String STATE_CLOSED;
|
||||||
|
|
||||||
public static String CANNOT_INITIALIZE;
|
public static String CANNOT_INITIALIZE;
|
||||||
public static String CONNECTOR_NOT_AVAILABLE;
|
public static String CONNECTOR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ VIEW_TITLE = View Title:
|
||||||
VIEW_SETTINGS = View Settings:
|
VIEW_SETTINGS = View Settings:
|
||||||
|
|
||||||
LIMITOUTPUT = Limit terminal output
|
LIMITOUTPUT = Limit terminal output
|
||||||
|
INVERT_COLORS = Invert terminal colors
|
||||||
BUFFERLINES = Terminal buffer lines:
|
BUFFERLINES = Terminal buffer lines:
|
||||||
SERIALTIMEOUT = Serial timeout (seconds):
|
SERIALTIMEOUT = Serial timeout (seconds):
|
||||||
NETWORKTIMEOUT = Network timeout (seconds):
|
NETWORKTIMEOUT = Network timeout (seconds):
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||||
public interface ITerminalViewControl {
|
public interface ITerminalViewControl {
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
void setFont(Font font);
|
void setFont(Font font);
|
||||||
|
void setInvertedColors(boolean invert);
|
||||||
Font getFont();
|
Font getFont();
|
||||||
Control getControl();
|
Control getControl();
|
||||||
boolean isDisposed();
|
boolean isDisposed();
|
||||||
|
|
|
@ -869,4 +869,7 @@ public class TerminalControl implements ITerminalControlForText, ITerminalContro
|
||||||
public void setScrollLock(boolean on) {
|
public void setScrollLock(boolean on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInvertedColors(boolean invert) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -906,4 +906,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
|
||||||
public void setScrollLock(boolean on) {
|
public void setScrollLock(boolean on) {
|
||||||
fCtlText.setScrollLock(on);
|
fCtlText.setScrollLock(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInvertedColors(boolean invert) {
|
||||||
|
fCtlText.setInvertedColors(invert);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,5 @@ public interface ILinelRenderer {
|
||||||
int getCellHeight();
|
int getCellHeight();
|
||||||
void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast);
|
void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int colFirst, int colLast);
|
||||||
void onFontChange();
|
void onFontChange();
|
||||||
|
void setInvertedColors(boolean invert);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class StyleMap {
|
||||||
Map fFontMap=new HashMap();
|
Map fFontMap=new HashMap();
|
||||||
private Point fCharSize;
|
private Point fCharSize;
|
||||||
private final Style fDefaultStyle;
|
private final Style fDefaultStyle;
|
||||||
|
private boolean fInvertColors;
|
||||||
StyleMap() {
|
StyleMap() {
|
||||||
Display display=Display.getCurrent();
|
Display display=Display.getCurrent();
|
||||||
fColorMap.put(StyleColor.getStyleColor("white"), new Color(display,255,255,255)); //$NON-NLS-1$
|
fColorMap.put(StyleColor.getStyleColor("white"), new Color(display,255,255,255)); //$NON-NLS-1$
|
||||||
|
@ -57,7 +58,7 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
public Color getForegrondColor(Style style) {
|
public Color getForegrondColor(Style style) {
|
||||||
style = defaultIfNull(style);
|
style = defaultIfNull(style);
|
||||||
if(style.isReverse())
|
if(isReverse(style))
|
||||||
return getColor(style.getBackground());
|
return getColor(style.getBackground());
|
||||||
else
|
else
|
||||||
return getColor(style.getForground());
|
return getColor(style.getForground());
|
||||||
|
@ -69,11 +70,22 @@ public class StyleMap {
|
||||||
}
|
}
|
||||||
public Color getBackgroundColor(Style style) {
|
public Color getBackgroundColor(Style style) {
|
||||||
style = defaultIfNull(style);
|
style = defaultIfNull(style);
|
||||||
if(style.isReverse())
|
if(isReverse(style))
|
||||||
return getColor(style.getForground());
|
return getColor(style.getForground());
|
||||||
else
|
else
|
||||||
return getColor(style.getBackground());
|
return getColor(style.getBackground());
|
||||||
}
|
}
|
||||||
|
private boolean isReverse(Style style) {
|
||||||
|
if(fInvertColors)
|
||||||
|
return !style.isReverse();
|
||||||
|
else
|
||||||
|
return style.isReverse();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void setInvertedColors(boolean invert) {
|
||||||
|
fInvertColors=invert;
|
||||||
|
|
||||||
|
}
|
||||||
// static Font getBoldFont(Font font) {
|
// static Font getBoldFont(Font font) {
|
||||||
// FontData fontDatas[] = font.getFontData();
|
// FontData fontDatas[] = font.getFontData();
|
||||||
// FontData data = fontDatas[0];
|
// FontData data = fontDatas[0];
|
||||||
|
|
|
@ -300,5 +300,10 @@ public class TextCanvas extends GridCanvas {
|
||||||
calculateGrid();
|
calculateGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInvertedColors(boolean invert) {
|
||||||
|
fCellRenderer.setInvertedColors(invert);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,4 +139,8 @@ public class TextLineRenderer implements ILinelRenderer {
|
||||||
public void onFontChange() {
|
public void onFontChange() {
|
||||||
fStyleMap.updateFont();
|
fStyleMap.updateFont();
|
||||||
}
|
}
|
||||||
|
public void setInvertedColors(boolean invert) {
|
||||||
|
fStyleMap.setInvertedColors(invert);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue