This commit is contained in:
commit
96a19b8523
|
@ -21,6 +21,8 @@ var blessed = require('blessed');
|
|||
// Create a screen object.
|
||||
var screen = blessed.screen();
|
||||
|
||||
screen.title = 'my window title';
|
||||
|
||||
// Create a box perfectly centered horizontally and vertically.
|
||||
var box = blessed.box({
|
||||
top: 'center',
|
||||
|
@ -194,6 +196,7 @@ The screen on which every other node renders.
|
|||
- **grabKeys** - whether the focused element grabs all keypresses.
|
||||
- **lockKeys** - prevent keypresses from being received by any element.
|
||||
- **hover** - the currently hovered element. only set if mouse events are bound.
|
||||
- **title** - set or get window title.
|
||||
|
||||
##### Events:
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ if (~argv.indexOf('-h') || ~argv.indexOf('--help')) {
|
|||
console.log('-s - Show seconds.');
|
||||
console.log('-n - No leading zero on hours.');
|
||||
console.log('-d - Show date box.');
|
||||
console.log('--skinny - Skinny text.');
|
||||
return process.exit(0);
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,8 @@ var date = blessed.box({
|
|||
date.hide();
|
||||
|
||||
var wid = ~argv.indexOf('--skinny') ? 1 : 2;
|
||||
var bch = ' ';
|
||||
// var bch = ' ';
|
||||
var bch = '│';
|
||||
var inverse = true;
|
||||
|
||||
// var bch = '*';
|
||||
|
@ -1030,7 +1032,7 @@ function updateTime() {
|
|||
|
||||
if (~argv.indexOf('-d')) {
|
||||
date.show();
|
||||
date.setContent(d.toISOString());
|
||||
date.setContent(d.toISOString().replace(/\.\d+/, ''));
|
||||
}
|
||||
|
||||
screen.render();
|
||||
|
|
10
lib/keys.js
10
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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1477,6 +1477,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
|
||||
*/
|
||||
|
@ -1798,6 +1807,8 @@ Program.prototype.setG = function(val) {
|
|||
// OSC Ps ; Pt BEL
|
||||
// Set Text Parameters.
|
||||
Program.prototype.setTitle = function(title) {
|
||||
this._title = title;
|
||||
|
||||
if (this.term('screen')) {
|
||||
// Tmux pane
|
||||
// if (process.env.TMUX) {
|
||||
|
@ -1805,6 +1816,7 @@ Program.prototype.setTitle = function(title) {
|
|||
// }
|
||||
return this._write('\x1bk' + title + '\x1b\\');
|
||||
}
|
||||
|
||||
return this._write('\x1b]0;' + title + '\x07');
|
||||
};
|
||||
|
||||
|
@ -2806,7 +2818,7 @@ Program.prototype.normalBuffer = function() {
|
|||
};
|
||||
|
||||
Program.prototype.enableMouse = function() {
|
||||
if (this.term('rxvt-unicode')) {
|
||||
if (this.term('rxvt-unicode') || process.env.VTE_VERSION) {
|
||||
return this.setMouse({
|
||||
urxvtMouse: true,
|
||||
allMotion: true
|
||||
|
|
|
@ -360,16 +360,25 @@ function Screen(options) {
|
|||
|
||||
this._maxListeners = Infinity;
|
||||
|
||||
if (this.options.handleUncaughtExceptions !== false) {
|
||||
process.on('uncaughtException', function(err) {
|
||||
reset();
|
||||
if (err) console.error(err.stack ? err.stack + '' : err + '');
|
||||
return process.exit(1);
|
||||
});
|
||||
}
|
||||
Screen.total++;
|
||||
|
||||
process.on('SIGTERM', function() {
|
||||
return process.exit(0);
|
||||
process.on('uncaughtException', function(err) {
|
||||
if (process.listeners('uncaughtException').length > Screen.total) {
|
||||
return;
|
||||
}
|
||||
reset();
|
||||
err = err || new Error('Uncaught Exception.');
|
||||
console.error(err.stack ? err.stack + '' : err + '');
|
||||
return process.exit(1);
|
||||
});
|
||||
|
||||
['SIGTERM', 'SIGINT', 'SIGQUIT'].forEach(function(signal) {
|
||||
process.on(signal, function() {
|
||||
if (process.listeners(signal).length > Screen.total) {
|
||||
return;
|
||||
}
|
||||
return process.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
|
@ -398,10 +407,20 @@ function Screen(options) {
|
|||
|
||||
Screen.global = null;
|
||||
|
||||
Screen.total = 0;
|
||||
|
||||
Screen.prototype.__proto__ = Node.prototype;
|
||||
|
||||
Screen.prototype.type = 'screen';
|
||||
|
||||
Screen.prototype.__defineGetter__('title', function() {
|
||||
return this.program.title;
|
||||
});
|
||||
|
||||
Screen.prototype.__defineSetter__('title', function(title) {
|
||||
return this.program.title = title;
|
||||
});
|
||||
|
||||
Screen.prototype.enter = function() {
|
||||
if (this.program.isAlt) return;
|
||||
this.program.alternateBuffer();
|
||||
|
@ -1093,8 +1112,7 @@ Screen.prototype.draw = function(start, end) {
|
|||
// are it does not support UTF8. This is probably
|
||||
// the "safest" way to do this. Should fix things
|
||||
// like sun-color.
|
||||
// if ((!this.unicode || this.tput.numbers.U8 !== 1) && ch > '~') {
|
||||
if ((!this.unicode || this.tput.numbers.U8 !== 1) && this.tput.utoa[ch]) {
|
||||
if ((!this.tput.unicode || this.tput.numbers.U8 !== 1) && ch > '~') {
|
||||
ch = this.tput.utoa[ch] || '?';
|
||||
}
|
||||
}
|
||||
|
@ -4754,8 +4772,8 @@ Form.prototype.reset = function() {
|
|||
case 'dir-manager':
|
||||
el.refresh(el.options.cwd);
|
||||
return;
|
||||
case 'passbox':
|
||||
el.clearInput();
|
||||
case 'terminal':
|
||||
el.write('');
|
||||
return;
|
||||
}
|
||||
el.children.forEach(fn);
|
||||
|
@ -6044,6 +6062,14 @@ function Listbar(options) {
|
|||
|
||||
Box.call(this, options);
|
||||
|
||||
if (!this.style.selected) {
|
||||
this.style.selected = {};
|
||||
}
|
||||
|
||||
if (!this.style.item) {
|
||||
this.style.item = {};
|
||||
}
|
||||
|
||||
if (options.commands || options.items) {
|
||||
this.setItems(options.commands || options.items);
|
||||
}
|
||||
|
@ -6073,7 +6099,6 @@ function Listbar(options) {
|
|||
self.emit('action', self.items[self.selected], self.selected);
|
||||
self.emit('select', self.items[self.selected], self.selected);
|
||||
var item = self.items[self.selected];
|
||||
//item.press();
|
||||
if (item._.cmd.callback) {
|
||||
item._.cmd.callback();
|
||||
}
|
||||
|
@ -6227,7 +6252,6 @@ Listbar.prototype.appendItem = function(item, callback) {
|
|||
});
|
||||
|
||||
var el = new Box(options);
|
||||
//var el = new Button(options);
|
||||
|
||||
this._[cmd.text] = el;
|
||||
cmd.element = el;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "blessed",
|
||||
"description": "A curses-like library for node.js.",
|
||||
"author": "Christopher Jeffrey",
|
||||
"version": "0.0.38",
|
||||
"version": "0.0.39",
|
||||
"main": "./lib/blessed.js",
|
||||
"bin": "./bin/tput.js",
|
||||
"preferGlobal": false,
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue