mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-22 15:48:07 +00:00
add setTerminal(). use terminal
option always for consistency.
This commit is contained in:
parent
72586faef9
commit
210c33d076
14
README.md
14
README.md
@ -333,7 +333,7 @@ The screen on which every other node renders.
|
|||||||
- __input/output__ - Input and output streams. `process.stdin`/`process.stdout`
|
- __input/output__ - Input and output streams. `process.stdin`/`process.stdout`
|
||||||
by default, however, it could be a `net.Socket` if you want to make a program
|
by default, however, it could be a `net.Socket` if you want to make a program
|
||||||
that runs over telnet or something of that nature.
|
that runs over telnet or something of that nature.
|
||||||
- __term__ - `TERM` name used for terminfo parsing. The `$TERM` env variable is
|
- __terminal__ - `TERM` name used for terminfo parsing. The `$TERM` env variable is
|
||||||
used by default.
|
used by default.
|
||||||
- __title__ - Set the terminal window title if possible.
|
- __title__ - Set the terminal window title if possible.
|
||||||
|
|
||||||
@ -359,6 +359,7 @@ The screen on which every other node renders.
|
|||||||
- __grabKeys__ - Whether the focused element grabs all keypresses.
|
- __grabKeys__ - Whether the focused element grabs all keypresses.
|
||||||
- __lockKeys__ - Prevent keypresses from being received by any element.
|
- __lockKeys__ - Prevent keypresses from being received by any element.
|
||||||
- __hover__ - The currently hovered element. Only set if mouse events are bound.
|
- __hover__ - The currently hovered element. Only set if mouse events are bound.
|
||||||
|
- __terminal__ - Get terminal name.
|
||||||
- __title__ - Set or get window title.
|
- __title__ - Set or get window title.
|
||||||
|
|
||||||
##### Events:
|
##### Events:
|
||||||
@ -443,6 +444,7 @@ The screen on which every other node renders.
|
|||||||
Also remove all global events relevant to the screen object. If all screen
|
Also remove all global events relevant to the screen object. If all screen
|
||||||
objects are destroyed, the node process is essentially reset to its initial
|
objects are destroyed, the node process is essentially reset to its initial
|
||||||
state.
|
state.
|
||||||
|
- __setTerminal(term)__ - Reset the terminal to `term`. Reloads terminfo.
|
||||||
|
|
||||||
|
|
||||||
#### Element (from Node)
|
#### Element (from Node)
|
||||||
@ -1377,7 +1379,7 @@ manager. Requires term.js and pty.js to be installed. See
|
|||||||
- __shell__ - Name of shell. `$SHELL` by default.
|
- __shell__ - Name of shell. `$SHELL` by default.
|
||||||
- __args__ - Args for shell.
|
- __args__ - Args for shell.
|
||||||
- __cursor__ - Can be `line`, `underline`, and `block`.
|
- __cursor__ - Can be `line`, `underline`, and `block`.
|
||||||
- __term__ - Terminal name (Default: `xterm`).
|
- __terminal__ - Terminal name (Default: `xterm`).
|
||||||
- __env__ - Object for process env.
|
- __env__ - Object for process env.
|
||||||
- Other options similar to term.js'.
|
- Other options similar to term.js'.
|
||||||
|
|
||||||
@ -2143,9 +2145,7 @@ telnet.createServer(function(client) {
|
|||||||
// https://tools.ietf.org/html/rfc884
|
// https://tools.ietf.org/html/rfc884
|
||||||
if (data.command === 'sb' && data.buf[3] === 1) {
|
if (data.command === 'sb' && data.buf[3] === 1) {
|
||||||
var TERM = data.buf.slice(4, -2).toString('ascii');
|
var TERM = data.buf.slice(4, -2).toString('ascii');
|
||||||
screen.program.terminal = TERM;
|
screen.setTerminal(TERM);
|
||||||
screen.program.tput.terminal = TERM;
|
|
||||||
screen.program.tput.setup();
|
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2181,7 +2181,7 @@ telnet.createServer(function(client) {
|
|||||||
smartCSR: true,
|
smartCSR: true,
|
||||||
input: client,
|
input: client,
|
||||||
output: client,
|
output: client,
|
||||||
term: 'xterm-256color'
|
terminal: 'xterm-256color'
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('close', function() {
|
client.on('close', function() {
|
||||||
@ -2264,7 +2264,7 @@ Windows users will need to explicitly set `term` when creating a screen like so
|
|||||||
This is now handled automatically):
|
This is now handled automatically):
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
var screen = blessed.screen({ term: 'windows-ansi' });
|
var screen = blessed.screen({ terminal: 'windows-ansi' });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,9 +23,7 @@ var server = telnet.createServer(function(client) {
|
|||||||
// https://tools.ietf.org/html/rfc884
|
// https://tools.ietf.org/html/rfc884
|
||||||
if (data.command === 'sb' && data.buf[3] === 1) {
|
if (data.command === 'sb' && data.buf[3] === 1) {
|
||||||
var TERM = data.buf.slice(4, -2).toString('ascii');
|
var TERM = data.buf.slice(4, -2).toString('ascii');
|
||||||
screen.program.terminal = TERM;
|
screen.setTerminal(TERM);
|
||||||
screen.program.tput.terminal = TERM;
|
|
||||||
screen.program.tput.setup();
|
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -61,7 +59,7 @@ var server = telnet.createServer(function(client) {
|
|||||||
smartCSR: true,
|
smartCSR: true,
|
||||||
input: client,
|
input: client,
|
||||||
output: client,
|
output: client,
|
||||||
term: 'xterm-256color'
|
terminal: 'xterm-256color'
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('close', function() {
|
client.on('close', function() {
|
||||||
|
@ -66,8 +66,8 @@ function Program(options) {
|
|||||||
this.scrollTop = 0;
|
this.scrollTop = 0;
|
||||||
this.scrollBottom = this.rows - 1;
|
this.scrollBottom = this.rows - 1;
|
||||||
|
|
||||||
this.terminal = options.term
|
this.terminal = options.terminal
|
||||||
|| options.terminal
|
|| options.term
|
||||||
|| process.env.TERM
|
|| process.env.TERM
|
||||||
|| (process.platform === 'win32' ? 'windows-ansi' : 'xterm');
|
|| (process.platform === 'win32' ? 'windows-ansi' : 'xterm');
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ Program.prototype.setupTput = function() {
|
|||||||
, write = this._write.bind(this);
|
, write = this._write.bind(this);
|
||||||
|
|
||||||
var tput = this.tput = new Tput({
|
var tput = this.tput = new Tput({
|
||||||
term: this.terminal,
|
terminal: this.terminal,
|
||||||
padding: options.padding,
|
padding: options.padding,
|
||||||
extended: options.extended,
|
extended: options.extended,
|
||||||
printf: options.printf,
|
printf: options.printf,
|
||||||
@ -292,6 +292,17 @@ Program.prototype.setupTput = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Program.prototype.setTerminal = function(terminal) {
|
||||||
|
if (!this.tput) {
|
||||||
|
this.terminal = terminal;
|
||||||
|
this.setupTput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.terminal = terminal;
|
||||||
|
this.tput.terminal = terminal;
|
||||||
|
this.tput.setup();
|
||||||
|
};
|
||||||
|
|
||||||
Program.prototype.has = function(name) {
|
Program.prototype.has = function(name) {
|
||||||
return this.tput
|
return this.tput
|
||||||
? this.tput.has(name)
|
? this.tput.has(name)
|
||||||
|
@ -37,12 +37,12 @@ function Tput(options) {
|
|||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = { term: options };
|
options = { terminal: options };
|
||||||
}
|
}
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.terminal = options.term
|
this.terminal = options.terminal
|
||||||
|| options.terminal
|
|| options.term
|
||||||
|| process.env.TERM
|
|| process.env.TERM
|
||||||
|| (process.platform === 'win32' ? 'windows-ansi' : 'xterm');
|
|| (process.platform === 'win32' ? 'windows-ansi' : 'xterm');
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ function Tput(options) {
|
|||||||
this.terminfoFile = options.terminfoFile;
|
this.terminfoFile = options.terminfoFile;
|
||||||
this.termcapFile = options.termcapFile;
|
this.termcapFile = options.termcapFile;
|
||||||
|
|
||||||
if (options.term || options.terminal) {
|
if (options.terminal || options.term) {
|
||||||
this.setup();
|
this.setup();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -51,7 +51,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,
|
terminal: options.terminal || options.term,
|
||||||
resizeTimeout: options.resizeTimeout,
|
resizeTimeout: options.resizeTimeout,
|
||||||
forceUnicode: options.forceUnicode,
|
forceUnicode: options.forceUnicode,
|
||||||
tput: true,
|
tput: true,
|
||||||
@ -252,6 +252,18 @@ Screen.prototype.__defineSetter__('title', function(title) {
|
|||||||
return this.program.title = title;
|
return this.program.title = title;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Screen.prototype.__defineGetter__('terminal', function() {
|
||||||
|
return this.program.terminal;
|
||||||
|
});
|
||||||
|
|
||||||
|
Screen.prototype.__defineSetter__('terminal', function(terminal) {
|
||||||
|
return this.program.terminal = terminal;
|
||||||
|
});
|
||||||
|
|
||||||
|
Screen.prototype.setTerminal = function(terminal) {
|
||||||
|
return this.program.setTerminal(terminal);
|
||||||
|
};
|
||||||
|
|
||||||
Screen.prototype.enter = function() {
|
Screen.prototype.enter = function() {
|
||||||
if (this.program.isAlt) return;
|
if (this.program.isAlt) return;
|
||||||
if (!this.cursor._set) {
|
if (!this.cursor._set) {
|
||||||
|
@ -48,7 +48,10 @@ function Terminal(options) {
|
|||||||
this.style.bg = this.style.bg || 'default';
|
this.style.bg = this.style.bg || 'default';
|
||||||
this.style.fg = this.style.fg || 'default';
|
this.style.fg = this.style.fg || 'default';
|
||||||
|
|
||||||
this.termName = options.term || process.env.TERM || 'xterm';
|
this.termName = options.terminal
|
||||||
|
|| options.term
|
||||||
|
|| process.env.TERM
|
||||||
|
|| 'xterm';
|
||||||
|
|
||||||
this.bootstrap();
|
this.bootstrap();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ function parseArg() {
|
|||||||
var argv = parseArg();
|
var argv = parseArg();
|
||||||
|
|
||||||
var tput = blessed.tput({
|
var tput = blessed.tput({
|
||||||
term: argv[0] !== 'all' && argv[0] !== 'rand'
|
terminal: argv[0] !== 'all' && argv[0] !== 'rand'
|
||||||
? argv[0] || __dirname + '/../usr/xterm'
|
? argv[0] || __dirname + '/../usr/xterm'
|
||||||
: null,
|
: null,
|
||||||
extended: true,
|
extended: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user