From 31a181e6a3052719fb3a4a4f60157f0457b712b8 Mon Sep 17 00:00:00 2001 From: nuintun Date: Mon, 30 Nov 2015 15:35:46 +0800 Subject: [PATCH] update files --- static/js/terminal/xterm.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/static/js/terminal/xterm.js b/static/js/terminal/xterm.js index 5f0177f..d7f50b3 100644 --- a/static/js/terminal/xterm.js +++ b/static/js/terminal/xterm.js @@ -941,16 +941,34 @@ var TERM_STRING = { * @constructor */ function AnsiTerminal(cols, rows, scrollLength){ + if (!(this instanceof AnsiTerminal)) { + return new AnsiTerminal(cols, rows, scrollLength); + } + this.rows = rows; this.cols = cols; this.scrollLength = scrollLength | 0; - this.send = function (s){}; // callback for writing back to stream - this.beep = function (tone, duration){}; // callback for sending console beep - this.changedMouseHandling = function (mode, protocol){}; // announce changes in mouse handling + // callback for writing back to stream + this.send = function (data){}; + // callback for sending console beep + this.beep = function (tone, duration){}; + // announce changes in mouse handling + this.changedMouseHandling = function (mode, protocol){}; + + // init ansi parser + this.AnsiParser = new AnsiParser(this); this.reset(); } +/** + * write + * @param data + */ +AnsiTerminal.prototype.write = function (data){ + this.AnsiParser.parse(data); +}; + /** Hard reset of the terminal. */ AnsiTerminal.prototype.reset = function (){ this.normal_screen = new ScreenBuffer(this.cols, this.rows, this.scrollLength);