Fixed: [Issue 27] Support for ANSI colors is broken in v1.1.0
diff --git a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/IVT100EmulatorBackend.java b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/IVT100EmulatorBackend.java
index 8519a39..3fa1525 100644
--- a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/IVT100EmulatorBackend.java
+++ b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/IVT100EmulatorBackend.java
@@ -92,10 +92,6 @@
*/
void deleteLines(int lineCount);
- Style getDefaultStyle();
-
- void setDefaultStyle(Style defaultStyle);
-
Style getStyle();
/**
diff --git a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100BackendTraceDecorator.java b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100BackendTraceDecorator.java
index 3e1d689..1c4a2a8 100644
--- a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100BackendTraceDecorator.java
+++ b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100BackendTraceDecorator.java
@@ -85,10 +85,6 @@
return backend.getCursorLine();
}
- @Override public Style getDefaultStyle() {
- return backend.getDefaultStyle();
- }
-
@Override public int getLines() {
return backend.getLines();
}
@@ -127,11 +123,6 @@
backend.setCursorLine(targetLine);
}
- @Override public void setDefaultStyle(Style defaultStyle) {
- out.println("setDefaultStyle(" + defaultStyle + ")");
- backend.setDefaultStyle(defaultStyle);
- }
-
@Override public void setDimensions(int lines, int cols) {
out.println("setDimensions(" + lines + "," + cols + ")");
backend.setDimensions(lines, cols);
diff --git a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100Emulator.java b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100Emulator.java
index f6625f8..32f0285 100644
--- a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100Emulator.java
+++ b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100Emulator.java
@@ -261,7 +261,7 @@
private void resetTerminal() {
text.eraseAll();
text.setCursor(0, 0);
- text.setStyle(text.getDefaultStyle());
+ text.setStyle(null);
}
// This method is called when we have parsed an OS Command escape sequence. The only one we support is
@@ -491,6 +491,9 @@
parameters[0].append('0');
}
Style style = text.getStyle();
+ if (style == null) {
+ style = defaultStyle();
+ }
// There are a non-zero number of ANSI parameters. Process each one in order.
int parameterCount = parameters.length;
int parameterIndex = 0;
@@ -499,7 +502,7 @@
switch (parameter) {
case 0:
// Reset all graphics modes.
- style = text.getDefaultStyle();
+ style = defaultStyle();
break;
case 1:
style = style.setBold(true);
@@ -585,6 +588,10 @@
text.setStyle(style);
}
+ private Style defaultStyle() {
+ return Style.getStyle("black", "white");
+ }
+
// Responds to an ANSI Device Status Report (DSR) command from the remote endpoint requesting the cursor position.
// Requests for other kinds of status are ignored.
private void processAnsiCommand_n() {
@@ -781,7 +788,7 @@
*/
public void resetState() {
ansiState = ANSISTATE_INITIAL;
- text.setStyle(text.getDefaultStyle());
+ text.setStyle(null);
}
private char getNextChar() throws IOException {
diff --git a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100EmulatorBackend.java b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100EmulatorBackend.java
index 4d56c59..daa5a55 100644
--- a/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100EmulatorBackend.java
+++ b/com.google.eclipse.elt.emulator/src/com/google/eclipse/elt/emulator/core/VT100EmulatorBackend.java
@@ -37,7 +37,6 @@
private int cursorColumn;
private int cursorLine;
- private Style defaultStyle;
private Style style;
private int lines;
private int columns;
@@ -59,7 +58,7 @@
terminal.cleanLine(line);
}
terminal.setDimensions(lines, terminal.getWidth());
- setStyle(getDefaultStyle());
+ setStyle(null);
setCursor(0, 0);
}
}
@@ -208,23 +207,8 @@
return true;
}
- @Override public Style getDefaultStyle() {
- synchronized (terminal) {
- return defaultStyle;
- }
- }
-
- @Override public void setDefaultStyle(Style defaultStyle) {
- synchronized (terminal) {
- this.defaultStyle = defaultStyle;
- }
- }
-
@Override public Style getStyle() {
synchronized (terminal) {
- if (style == null) {
- return defaultStyle;
- }
return style;
}
}