Better Windows support

This commit is contained in:
mscdex 2013-08-02 21:59:49 -04:00
parent b7fa80cc2e
commit a1616aec0a
4 changed files with 22 additions and 4 deletions

View File

@ -53,8 +53,8 @@ box.on('click', function(data) {
screen.render(); screen.render();
}); });
// If box is focused, handle `enter` and give us some more content. // If box is focused, handle `enter`/`return` and give us some more content.
box.key('enter', function() { box.key(['enter', 'return'], function(ch, key) {
box.setContent('{right}Even different {black-fg}content{/black-fg}.{/right}\n'); box.setContent('{right}Even different {black-fg}content{/black-fg}.{/right}\n');
box.setLine(1, 'bar'); box.setLine(1, 'bar');
box.insertLine(1, 'foo'); box.insertLine(1, 'foo');
@ -73,6 +73,16 @@ box.focus();
screen.render(); 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 ## High-level Documentation

View File

@ -73,6 +73,13 @@ Tput.prototype.setup = function() {
if (this.debug) { if (this.debug) {
throw e; throw e;
} }
if (process.platform === 'win32') {
try {
this.injectTerminfo(__dirname + '/../usr/' + this.terminal);
return;
} catch (e) {}
}
this._useXtermI(); this._useXtermI();
} }
}; };
@ -112,7 +119,7 @@ Tput.prototype.readTerminfo = function(term) {
, file , file
, info; , info;
file = this._prefix(term); file = path.normalize(this._prefix(term));
data = fs.readFileSync(file); data = fs.readFileSync(file);
info = this.parseTerminfo(data, file); info = this.parseTerminfo(data, file);
@ -125,7 +132,7 @@ Tput.prototype.readTerminfo = function(term) {
Tput._prefix = Tput._prefix =
Tput.prototype._prefix = function(term) { Tput.prototype._prefix = function(term) {
return (term && term[0] === '/' && term) return (term && (~term.indexOf(path.sep)) && term)
|| (term && this.terminfoFile) || (term && this.terminfoFile)
|| this._tprefix(this.terminfoPrefix, term) || this._tprefix(this.terminfoPrefix, term)
|| this._tprefix(process.env.TERMINFO, term) || this._tprefix(process.env.TERMINFO, term)

View File

@ -277,6 +277,7 @@ function Screen(options) {
log: options.log, log: options.log,
debug: options.debug, debug: options.debug,
dump: options.dump, dump: options.dump,
term: options.term,
tput: true, tput: true,
buffer: true, buffer: true,
zero: true zero: true

BIN
usr/windows-ansi Normal file

Binary file not shown.