From 547812928e06a1a0830f21141593b67274fecc84 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 29 Jan 2015 20:08:23 -0800 Subject: [PATCH] window title. potential enter/return fix for keys. --- lib/keys.js | 10 ++++++++++ lib/program.js | 17 +++++++++-------- test/widget.js | 3 ++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/keys.js b/lib/keys.js index b331783..8950648 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -126,6 +126,8 @@ function emitKey(stream, s) { } else if (s === '\n') { // enter, should have been called linefeed key.name = 'enter'; + // linefeed + // key.name = 'linefeed'; } else if (s === '\t') { // tab @@ -298,5 +300,13 @@ function emitKey(stream, s) { if (key || ch) { stream.emit('keypress', ch, key); + // if (key && key.name === 'return') { + // var nkey = {}; + // Object.keys(key).forEach(function(k) { + // nkey[k] = key[k]; + // }); + // nkey.name = 'enter'; + // stream.emit('keypress', ch, nkey); + // } } } diff --git a/lib/program.js b/lib/program.js index f438168..7f9b11d 100644 --- a/lib/program.js +++ b/lib/program.js @@ -1387,6 +1387,15 @@ Program.prototype.repeat = function(ch, i) { return Array(i + 1).join(ch); }; +Program.prototype.__defineGetter__('title', function() { + return this._title; +}); + +Program.prototype.__defineSetter__('title', function(title) { + this.setTitle(title); + return this._title; +}); + /** * Normal */ @@ -1721,14 +1730,6 @@ Program.prototype.setTitle = function(title) { return this._write('\x1b]0;' + title + '\x07'); }; -Program.prototype.__defineGetter__('title', function() { - return this._title; -}); - -Program.prototype.__defineSetter__('title', function(title) { - return this.setTitle(title); -}); - // OSC Ps ; Pt ST // OSC Ps ; Pt BEL // Reset colors diff --git a/test/widget.js b/test/widget.js index f32f11e..bf88729 100644 --- a/test/widget.js +++ b/test/widget.js @@ -2,7 +2,8 @@ var blessed = require('../') , screen; screen = blessed.screen({ - dump: __dirname + '/logs/widget.log' + dump: __dirname + '/logs/widget.log', + title: 'widget test' }); screen.append(blessed.text({