Skip to content

Commit 512d3e2

Browse files
committed
Add support for String Terminator to be ESC \
This fixes support to properly identify the end of OSC control sequences which can be terminated with a BEL or ESC \. Fixes eclipse-cdt/cdt#831
1 parent 2c096bf commit 512d3e2

File tree

1 file changed

+18
-1
lines changed
  • terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator

1 file changed

+18
-1
lines changed

terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ public class VT100Emulator implements ControlListener {
9797
*/
9898
private static final int ANSISTATE_EXPECTING_CHARSET_DESIGNATION = 5;
9999

100+
/**
101+
* For cases where the OSC (OS Command) ends with a multi-byte ST (i.e. ESC \)
102+
* we use this extra state.
103+
*/
104+
private static final int ANSISTATE_EXPECTING_OS_COMMAND_END = 6;
105+
100106
/**
101107
* This field holds the current state of the Finite TerminalState Automaton (FSA)
102108
* that recognizes ANSI escape sequences.
@@ -428,16 +434,27 @@ private void processNewText() throws IOException {
428434
break;
429435

430436
case ANSISTATE_EXPECTING_OS_COMMAND:
431-
// A BEL (\u0007) character marks the end of the OSC sequence.
437+
// A BEL (\u0007) or ESC \ ('\e\\') character marks the end of the OSC sequence.
432438

433439
if (character == '\u0007') {
434440
ansiState = ANSISTATE_INITIAL;
435441
processAnsiOsCommand();
442+
} else if (character == '\u001b') {
443+
ansiState = ANSISTATE_EXPECTING_OS_COMMAND_END;
436444
} else {
437445
ansiOsCommand.append(character);
438446
}
439447
break;
440448

449+
case ANSISTATE_EXPECTING_OS_COMMAND_END:
450+
ansiState = ANSISTATE_INITIAL;
451+
if (character == '\\') {
452+
processAnsiOsCommand();
453+
} else {
454+
Logger.log("Unsupported escape sequence: escape '" + ansiOsCommand + " \\e" + character + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
455+
}
456+
break;
457+
441458
case ANSISTATE_EXPECTING_DEC_PRIVATE_COMMAND:
442459
// Parameters can appear after the '[?' in an escape sequence, but they
443460
// are optional.

0 commit comments

Comments
 (0)