Skip to content

Commit 4b24c09

Browse files
committed
Filter out escape sequence 'character set' select
reported #92 fix after #95 PrintStream copy of OutputStream
1 parent 5f8eb45 commit 4b24c09

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

jansi/src/main/java/org/fusesource/jansi/AnsiOutputStream.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ protected void processUnknownOperatingSystemCommand(int command, String param) {
753753
* @param options
754754
* @return true if the charcter set select command was processed.
755755
*/
756-
private boolean processCharsetSelect(ArrayList<Object> options) throws IOException {
756+
private boolean processCharsetSelect(ArrayList<Object> options) {
757757
int set = optionInt(options, 0);
758758
char seq = ((Character) options.get(1)).charValue();
759759
processCharsetSelect(set, seq);

jansi/src/main/java/org/fusesource/jansi/AnsiPrintStream.java

+29
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public AnsiPrintStream(PrintStream ps) { // expected diff with AnsiOutputStream.
6161
private static final int LOOKING_FOR_OSC_COMMAND_END = 6;
6262
private static final int LOOKING_FOR_OSC_PARAM = 7;
6363
private static final int LOOKING_FOR_ST = 8;
64+
private static final int LOOKING_FOR_CHARSET = 9;
6465

6566
int state = LOOKING_FOR_FIRST_ESC_CHAR;
6667

@@ -69,6 +70,8 @@ public AnsiPrintStream(PrintStream ps) { // expected diff with AnsiOutputStream.
6970
private static final int SECOND_OSC_CHAR = ']';
7071
private static final int BEL = 7;
7172
private static final int SECOND_ST_CHAR = '\\';
73+
private static final int SECOND_CHARSET0_CHAR = '(';
74+
private static final int SECOND_CHARSET1_CHAR = ')';
7275

7376
@Override
7477
protected boolean filter(int data) { // expected diff with AnsiOutputStream.java
@@ -87,6 +90,12 @@ protected boolean filter(int data) { // expected diff with AnsiOutputStream.java
8790
state = LOOKING_FOR_NEXT_ARG;
8891
} else if (data == SECOND_OSC_CHAR) {
8992
state = LOOKING_FOR_OSC_COMMAND;
93+
} else if (data == SECOND_CHARSET0_CHAR) {
94+
options.add(new Integer('0'));
95+
state = LOOKING_FOR_CHARSET;
96+
} else if (data == SECOND_CHARSET1_CHAR) {
97+
options.add(new Integer('1'));
98+
state = LOOKING_FOR_CHARSET;
9099
} else {
91100
reset(false);
92101
}
@@ -189,6 +198,11 @@ protected boolean filter(int data) { // expected diff with AnsiOutputStream.java
189198
state = LOOKING_FOR_OSC_PARAM;
190199
}
191200
break;
201+
202+
case LOOKING_FOR_CHARSET:
203+
options.add(new Character((char) data));
204+
reset(processCharsetSelect(options));
205+
break;
192206
}
193207

194208
// Is it just too long?
@@ -726,6 +740,21 @@ protected void processChangeWindowTitle(String label) {
726740
protected void processUnknownOperatingSystemCommand(int command, String param) {
727741
}
728742

743+
/**
744+
* Process character set sequence.
745+
* @param options
746+
* @return true if the charcter set select command was processed.
747+
*/
748+
private boolean processCharsetSelect(ArrayList<Object> options) {
749+
int set = optionInt(options, 0);
750+
char seq = ((Character) options.get(1)).charValue();
751+
processCharsetSelect(set, seq);
752+
return true;
753+
}
754+
755+
protected void processCharsetSelect(int set, char seq) {
756+
}
757+
729758
private int optionInt(ArrayList<Object> options, int index) {
730759
if (options.size() <= index)
731760
throw new IllegalArgumentException();

0 commit comments

Comments
 (0)