-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter out escape sequence 'character set' select
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ public AnsiPrintStream(PrintStream ps) { // expected diff with AnsiOutputStream. | |
private static final int LOOKING_FOR_OSC_COMMAND_END = 6; | ||
private static final int LOOKING_FOR_OSC_PARAM = 7; | ||
private static final int LOOKING_FOR_ST = 8; | ||
private static final int LOOKING_FOR_CHARSET = 9; | ||
|
||
int state = LOOKING_FOR_FIRST_ESC_CHAR; | ||
|
||
|
@@ -69,6 +70,8 @@ public AnsiPrintStream(PrintStream ps) { // expected diff with AnsiOutputStream. | |
private static final int SECOND_OSC_CHAR = ']'; | ||
private static final int BEL = 7; | ||
private static final int SECOND_ST_CHAR = '\\'; | ||
private static final int SECOND_CHARSET0_CHAR = '('; | ||
private static final int SECOND_CHARSET1_CHAR = ')'; | ||
|
||
@Override | ||
protected boolean filter(int data) { // expected diff with AnsiOutputStream.java | ||
|
@@ -87,6 +90,12 @@ protected boolean filter(int data) { // expected diff with AnsiOutputStream.java | |
state = LOOKING_FOR_NEXT_ARG; | ||
} else if (data == SECOND_OSC_CHAR) { | ||
state = LOOKING_FOR_OSC_COMMAND; | ||
} else if (data == SECOND_CHARSET0_CHAR) { | ||
options.add(new Integer('0')); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hboutemy
Author
Collaborator
|
||
state = LOOKING_FOR_CHARSET; | ||
} else if (data == SECOND_CHARSET1_CHAR) { | ||
options.add(new Integer('1')); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
state = LOOKING_FOR_CHARSET; | ||
} else { | ||
reset(false); | ||
} | ||
|
@@ -189,6 +198,11 @@ protected boolean filter(int data) { // expected diff with AnsiOutputStream.java | |
state = LOOKING_FOR_OSC_PARAM; | ||
} | ||
break; | ||
|
||
case LOOKING_FOR_CHARSET: | ||
options.add(new Character((char) data)); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
reset(processCharsetSelect(options)); | ||
break; | ||
} | ||
|
||
// Is it just too long? | ||
|
@@ -726,6 +740,21 @@ protected void processChangeWindowTitle(String label) { | |
protected void processUnknownOperatingSystemCommand(int command, String param) { | ||
} | ||
|
||
/** | ||
* Process character set sequence. | ||
* @param options | ||
* @return true if the charcter set select command was processed. | ||
*/ | ||
private boolean processCharsetSelect(ArrayList<Object> options) { | ||
int set = optionInt(options, 0); | ||
char seq = ((Character) options.get(1)).charValue(); | ||
processCharsetSelect(set, seq); | ||
return true; | ||
} | ||
|
||
protected void processCharsetSelect(int set, char seq) { | ||
} | ||
|
||
private int optionInt(ArrayList<Object> options, int index) { | ||
if (options.size() <= index) | ||
throw new IllegalArgumentException(); | ||
|
Don't use the constructor, use
valueOf
.