From a1616aec0ad7d073b66c81cd116e9e4c67f17ddc Mon Sep 17 00:00:00 2001 From: mscdex Date: Fri, 2 Aug 2013 21:59:49 -0400 Subject: [PATCH] Better Windows support --- README.md | 14 ++++++++++++-- lib/tput.js | 11 +++++++++-- lib/widget.js | 1 + usr/windows-ansi | Bin 0 -> 1481 bytes 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 usr/windows-ansi diff --git a/README.md b/README.md index aa58a12..b4896c0 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,8 @@ box.on('click', function(data) { screen.render(); }); -// If box is focused, handle `enter` and give us some more content. -box.key('enter', function() { +// If box is focused, handle `enter`/`return` and give us some more content. +box.key(['enter', 'return'], function(ch, key) { box.setContent('{right}Even different {black-fg}content{/black-fg}.{/right}\n'); box.setLine(1, 'bar'); box.insertLine(1, 'foo'); @@ -73,6 +73,16 @@ box.focus(); screen.render(); ``` +## Windows compatibility + +Currently there is no mouse or 'resize' event support on Windows. + +Windows users will need to explicitly set `term` when creating a screen like so: + +``` js +var screen = blessed.screen({ term: 'windows-ansi' }); +``` + ## High-level Documentation diff --git a/lib/tput.js b/lib/tput.js index 7679b5e..d3ba62e 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -73,6 +73,13 @@ Tput.prototype.setup = function() { if (this.debug) { throw e; } + + if (process.platform === 'win32') { + try { + this.injectTerminfo(__dirname + '/../usr/' + this.terminal); + return; + } catch (e) {} + } this._useXtermI(); } }; @@ -112,7 +119,7 @@ Tput.prototype.readTerminfo = function(term) { , file , info; - file = this._prefix(term); + file = path.normalize(this._prefix(term)); data = fs.readFileSync(file); info = this.parseTerminfo(data, file); @@ -125,7 +132,7 @@ Tput.prototype.readTerminfo = function(term) { Tput._prefix = Tput.prototype._prefix = function(term) { - return (term && term[0] === '/' && term) + return (term && (~term.indexOf(path.sep)) && term) || (term && this.terminfoFile) || this._tprefix(this.terminfoPrefix, term) || this._tprefix(process.env.TERMINFO, term) diff --git a/lib/widget.js b/lib/widget.js index 5a41c2a..6765d42 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -277,6 +277,7 @@ function Screen(options) { log: options.log, debug: options.debug, dump: options.dump, + term: options.term, tput: true, buffer: true, zero: true diff --git a/usr/windows-ansi b/usr/windows-ansi new file mode 100644 index 0000000000000000000000000000000000000000..50864235f466bd89a7022f880fb565e26ca7e298 GIT binary patch literal 1481 zcmds%O=uHQ5Xa}O#Rf~ELJzHx(#vYJjb@Y07po@KfK^in+CyoOnr4e#ZPJ)TTWwSD zb-#MDL7Ioy2%*x=bXk^v5~%`UB)2(lR}#7xacc&?ovql4ui7 z-%imjdK#m8JqX?nCB$Xet4$ea2KzUaW>y-1S$B~%*j=dIn>~Vn*@2fdVaNgA zm>Eer&?x3MW{P{6z&kf#*a3bI)qn{b#F;!71m!uUCi`W5oXf0J(P;w)yl*+dg;gyo zYm7mlYGKHYs=%-njQ|x3qrjMjagHL4x94*`Kz$wk8~t57x&y1nT5?ObzWYB<-aYZ^ zhV_lQ= z!@x)pCLw3FfD#O;;Yc(VKbl8~6^d(WoDV-_9to4`kPpYY4cZR%LG~TUi1R$S literal 0 HcmV?d00001