diff --git a/lib/program.js b/lib/program.js index 2fca944..b1cbf69 100644 --- a/lib/program.js +++ b/lib/program.js @@ -35,6 +35,8 @@ function Program(input, output) { this.terminal = process.env.TERM || 'xterm'; this.listen(); + + Program.global = this; } Program.prototype.__proto__ = EventEmitter.prototype; @@ -540,7 +542,7 @@ Program.prototype._bindResponse = function(s) { // OSC L label ST // Ps = 2 1 -> Report xterm window's title. Result is OSC l // label ST - if (parts = /^\x1b\](l|L)([^\x07\x1b]*)(?:\x07|\\\x1b)/.exec(s)) { + if (parts = /^\x1b\](l|L)([^\x07\x1b]*)(?:\x07|\x1b\\)/.exec(s)) { if (parts[1] === 'L') { return this.emit('response', { windowIconLabel: parts[2] @@ -658,6 +660,15 @@ Program.prototype.rmove = function(x, y) { this.rsetY(y); }; +Program.prototype.simpleInsert = function(ch, i, attr) { + return this.write(this.repeat(ch, i), attr); +}; + +Program.prototype.repeat = function(ch, i) { + if (!(i >= 0)) i = 0; + return Array(i + 1).join(ch); +}; + /** * Normal */