diff --git a/src/js/ansi_parser.js b/src/js/ansi_parser.js index 449b59d..4078f75 100644 --- a/src/js/ansi_parser.js +++ b/src/js/ansi_parser.js @@ -1,5 +1,7 @@ // Parser for ANSI escape sequence +import { b2u } from './string_util'; + export function AnsiParser(termbuf) { this.termbuf = termbuf; this.state = AnsiParser.STATE_TEXT; @@ -10,6 +12,7 @@ AnsiParser.STATE_TEXT = 0; AnsiParser.STATE_ESC = 1; AnsiParser.STATE_CSI = 2; AnsiParser.STATE_C1 = 3; +AnsiParser.STATE_OSC = 4; AnsiParser.prototype.feed = function(data) { var term = this.termbuf; @@ -217,6 +220,49 @@ AnsiParser.prototype.feed = function(data) { this.esc += ch; } break; + case AnsiParser.STATE_OSC: + if (ch == '\\' && this.esc[this.esc.length - 1] == '\x1b') { + // ST = ESC \ + this.esc.pop(); + ch = '\x07'; + } + if (ch == '\x07') { + var params=this.esc.split(';'); + var firstChar = ''; + if (params[0] && (params[0].charAt(0)<'0' || params[0].charAt(0)>'9')) { + if (firstChar) { // unknown OSC + //dump('unknown OSC: ' + this.esc + ch + '\n'); + this.state = AnsiParser.STATE_TEXT; + this.esc = ''; + break; + } + } + for (var j=0; j