cleanup and fixes.
This commit is contained in:
parent
5e143e7fe5
commit
a79e8106ea
|
@ -122,6 +122,8 @@ exports.mixColors = function(c1, c2, alpha) {
|
|||
};
|
||||
|
||||
exports.blend = function blend(attr, attr2, alpha) {
|
||||
var name, i, c, nc;
|
||||
|
||||
var bg = attr & 0x1ff;
|
||||
if (attr2 != null) {
|
||||
var bg2 = attr2 & 0x1ff;
|
||||
|
@ -136,12 +138,12 @@ exports.blend = function blend(attr, attr2, alpha) {
|
|||
} else if (bg >= 8 && bg <= 15) {
|
||||
bg -= 8;
|
||||
} else {
|
||||
var name = exports.ncolors[bg];
|
||||
name = exports.ncolors[bg];
|
||||
if (name) {
|
||||
for (var i = 0; i < exports.ncolors.length; i++) {
|
||||
for (i = 0; i < exports.ncolors.length; i++) {
|
||||
if (name === exports.ncolors[i] && i !== bg) {
|
||||
var c = exports.vcolors[bg];
|
||||
var nc = exports.vcolors[i];
|
||||
c = exports.vcolors[bg];
|
||||
nc = exports.vcolors[i];
|
||||
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
|
||||
blend._cache[bg] = i;
|
||||
bg = i;
|
||||
|
@ -176,12 +178,12 @@ exports.blend = function blend(attr, attr2, alpha) {
|
|||
} else if (fg >= 8 && fg <= 15) {
|
||||
fg -= 8;
|
||||
} else {
|
||||
var name = exports.ncolors[fg];
|
||||
name = exports.ncolors[fg];
|
||||
if (name) {
|
||||
for (var i = 0; i < exports.ncolors.length; i++) {
|
||||
for (i = 0; i < exports.ncolors.length; i++) {
|
||||
if (name === exports.ncolors[i] && i !== fg) {
|
||||
var c = exports.vcolors[fg];
|
||||
var nc = exports.vcolors[i];
|
||||
c = exports.vcolors[fg];
|
||||
nc = exports.vcolors[i];
|
||||
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
|
||||
blend._cache[fg] = i;
|
||||
fg = i;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
var net = require('net');
|
||||
var fs = require('fs');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util')
|
||||
|
||||
var GPM_USE_MAGIC = false;
|
||||
|
||||
|
@ -33,8 +32,9 @@ var GPM_SOCKET = '/dev/gpmctl';
|
|||
// } Gpm_Connect;
|
||||
|
||||
function send_config(socket, Gpm_Connect, callback) {
|
||||
var buffer;
|
||||
if (GPM_USE_MAGIC) {
|
||||
var buffer = new Buffer(20);
|
||||
buffer = new Buffer(20);
|
||||
buffer.writeUInt32LE(GPM_MAGIC, 0);
|
||||
buffer.writeUInt16LE(Gpm_Connect.eventMask, 4);
|
||||
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 6);
|
||||
|
@ -43,7 +43,7 @@ function send_config(socket, Gpm_Connect, callback) {
|
|||
buffer.writeInt16LE(process.pid, 12);
|
||||
buffer.writeInt16LE(Gpm_Connect.vc, 16);
|
||||
} else {
|
||||
var buffer = new Buffer(16);
|
||||
buffer = new Buffer(16);
|
||||
buffer.writeUInt16LE(Gpm_Connect.eventMask, 0);
|
||||
buffer.writeUInt16LE(Gpm_Connect.defaultMask, 2);
|
||||
buffer.writeUInt16LE(Gpm_Connect.minMod, 4);
|
||||
|
@ -183,7 +183,7 @@ function GpmClient(options) {
|
|||
}
|
||||
});
|
||||
|
||||
gpm.on('error', function(err) {
|
||||
gpm.on('error', function() {
|
||||
self.stop();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var StringDecoder = require('string_decoder').StringDecoder;
|
||||
|
||||
// NOTE: node <=v0.8.x has no EventEmitter.listenerCount
|
||||
function listenerCount(stream, event) {
|
||||
|
@ -56,7 +55,7 @@ function emitKeypressEvents(stream) {
|
|||
}
|
||||
|
||||
function onNewListener(event) {
|
||||
if (event == 'keypress') {
|
||||
if (event === 'keypress') {
|
||||
stream.on('data', onData);
|
||||
stream.removeListener('newListener', onNewListener);
|
||||
}
|
||||
|
|
123
lib/program.js
123
lib/program.js
|
@ -572,7 +572,15 @@ Program.prototype.bindMouse = function() {
|
|||
Program.prototype._bindMouse = function(s, buf) {
|
||||
var self = this
|
||||
, key
|
||||
, parts;
|
||||
, parts
|
||||
, b
|
||||
, x
|
||||
, y
|
||||
, mod
|
||||
, params
|
||||
, down
|
||||
, page
|
||||
, button;
|
||||
|
||||
key = {
|
||||
name: undefined,
|
||||
|
@ -616,9 +624,9 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
|| (by > 0x00 && by < 0x20)
|
||||
|| (buf[4] > 223 && buf[4] < 248 && buf.length === 6)
|
||||
|| (buf[5] > 223 && buf[5] < 248 && buf.length === 6))) {
|
||||
var b = buf[3]
|
||||
, x = buf[4]
|
||||
, y = buf[5];
|
||||
b = buf[3];
|
||||
x = buf[4];
|
||||
y = buf[5];
|
||||
|
||||
// unsigned char overflow.
|
||||
if (x < 0x20) x += 0xff;
|
||||
|
@ -634,10 +642,9 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
|
||||
// XTerm / X10
|
||||
if (parts = /^\x1b\[M([\x00\u0020-\uffff]{3})/.exec(s)) {
|
||||
var b = parts[1].charCodeAt(0)
|
||||
, x = parts[1].charCodeAt(1)
|
||||
, y = parts[1].charCodeAt(2)
|
||||
, mod;
|
||||
b = parts[1].charCodeAt(0);
|
||||
x = parts[1].charCodeAt(1);
|
||||
y = parts[1].charCodeAt(2);
|
||||
|
||||
key.name = 'mouse';
|
||||
key.type = 'X10';
|
||||
|
@ -670,7 +677,7 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
delete this._lastButton;
|
||||
} else {
|
||||
key.action = 'mousedown';
|
||||
var button = b & 3;
|
||||
button = b & 3;
|
||||
key.button =
|
||||
button === 0 ? 'left'
|
||||
: button === 1 ? 'middle'
|
||||
|
@ -702,10 +709,10 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
|
||||
// URxvt
|
||||
if (parts = /^\x1b\[(\d+;\d+;\d+)M/.exec(s)) {
|
||||
var params = parts[1].split(';')
|
||||
, b = +params[0]
|
||||
, x = +params[1]
|
||||
, y = +params[2];
|
||||
params = parts[1].split(';');
|
||||
b = +params[0];
|
||||
x = +params[1];
|
||||
y = +params[2];
|
||||
|
||||
key.name = 'mouse';
|
||||
key.type = 'urxvt';
|
||||
|
@ -742,7 +749,7 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
delete this._lastButton;
|
||||
} else {
|
||||
key.action = 'mousedown';
|
||||
var button = b & 3;
|
||||
button = b & 3;
|
||||
key.button =
|
||||
button === 0 ? 'left'
|
||||
: button === 1 ? 'middle'
|
||||
|
@ -775,11 +782,11 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
|
||||
// SGR
|
||||
if (parts = /^\x1b\[<(\d+;\d+;\d+)([mM])/.exec(s)) {
|
||||
var down = parts[2] === 'M'
|
||||
, params = parts[1].split(';')
|
||||
, b = +params[0]
|
||||
, x = +params[1]
|
||||
, y = +params[2];
|
||||
down = parts[2] === 'M';
|
||||
params = parts[1].split(';');
|
||||
b = +params[0];
|
||||
x = +params[1];
|
||||
y = +params[2];
|
||||
|
||||
key.name = 'mouse';
|
||||
key.type = 'sgr';
|
||||
|
@ -803,7 +810,7 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
key.action = down
|
||||
? 'mousedown'
|
||||
: 'mouseup';
|
||||
var button = b & 3;
|
||||
button = b & 3;
|
||||
key.button =
|
||||
button === 0 ? 'left'
|
||||
: button === 1 ? 'middle'
|
||||
|
@ -835,11 +842,11 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
// The xterm mouse documentation says there is a
|
||||
// `<` prefix, the DECRQLP says there is no prefix.
|
||||
if (parts = /^\x1b\[<(\d+;\d+;\d+;\d+)&w/.exec(s)) {
|
||||
var params = parts[1].split(';')
|
||||
, b = +params[0]
|
||||
, x = +params[1]
|
||||
, y = +params[2]
|
||||
, page = +params[3];
|
||||
params = parts[1].split(';');
|
||||
b = +params[0];
|
||||
x = +params[1];
|
||||
y = +params[2];
|
||||
page = +params[3];
|
||||
|
||||
key.name = 'mouse';
|
||||
key.type = 'dec';
|
||||
|
@ -848,6 +855,7 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
key.buf = buf;
|
||||
key.x = x;
|
||||
key.y = y;
|
||||
key.page = page;
|
||||
|
||||
if (this.zero) key.x--, key.y--;
|
||||
|
||||
|
@ -868,9 +876,9 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
|
||||
// vt300
|
||||
if (parts = /^\x1b\[24([0135])~\[(\d+),(\d+)\]\r/.exec(s)) {
|
||||
var b = +parts[1]
|
||||
, x = +parts[2]
|
||||
, y = +parts[3];
|
||||
b = +parts[1];
|
||||
x = +parts[2];
|
||||
y = +parts[3];
|
||||
|
||||
key.name = 'mouse';
|
||||
key.type = 'vt300';
|
||||
|
@ -909,7 +917,7 @@ Program.prototype._bindMouse = function(s, buf) {
|
|||
// gpm support for linux vc
|
||||
Program.prototype.enableGpm = function() {
|
||||
var self = this;
|
||||
var gpmclient = require('./gpmclient')
|
||||
var gpmclient = require('./gpmclient');
|
||||
|
||||
if (this.gpm) return;
|
||||
|
||||
|
@ -1032,8 +1040,7 @@ Program.prototype.bindResponse = function() {
|
|||
};
|
||||
|
||||
Program.prototype._bindResponse = function(s) {
|
||||
var self = this
|
||||
, out = {}
|
||||
var out = {}
|
||||
, parts;
|
||||
|
||||
if (Buffer.isBuffer(s)) {
|
||||
|
@ -1319,7 +1326,7 @@ Program.prototype._bindResponse = function(s) {
|
|||
out.type = 'window-state';
|
||||
out.state = parts[1] === '1'
|
||||
? 'non-iconified'
|
||||
: 'iconified'
|
||||
: 'iconified';
|
||||
|
||||
// LEGACY
|
||||
out.windowState = out.state;
|
||||
|
@ -1649,7 +1656,7 @@ Program.prototype._buffer = function(text) {
|
|||
return true;
|
||||
};
|
||||
|
||||
Program.prototype.flush = function(text) {
|
||||
Program.prototype.flush = function() {
|
||||
if (!this._buf) return;
|
||||
this._owrite(this._buf);
|
||||
this._buf = '';
|
||||
|
@ -1784,7 +1791,7 @@ Program.prototype.simpleInsert = function(ch, i, attr) {
|
|||
};
|
||||
|
||||
Program.prototype.repeat = function(ch, i) {
|
||||
if (!(i >= 0)) i = 0;
|
||||
if (!i || i < 0) i = 0;
|
||||
return Array(i + 1).join(ch);
|
||||
};
|
||||
|
||||
|
@ -2044,7 +2051,7 @@ Program.prototype.restoreCursor = function(key, hide) {
|
|||
|
||||
// Save Cursor Locally
|
||||
Program.prototype.lsaveCursor = function(key) {
|
||||
var key = key || 'local';
|
||||
key = key || 'local';
|
||||
this._saved = this._saved || {};
|
||||
this._saved[key] = this._saved[key] || {};
|
||||
this._saved[key].x = this.x;
|
||||
|
@ -2054,7 +2061,8 @@ Program.prototype.lsaveCursor = function(key) {
|
|||
|
||||
// Restore Cursor Locally
|
||||
Program.prototype.lrestoreCursor = function(key, hide) {
|
||||
var key = key || 'local', pos;
|
||||
var pos;
|
||||
key = key || 'local';
|
||||
if (!this._saved || !this._saved[key]) return;
|
||||
pos = this._saved[key];
|
||||
//delete this._saved[key];
|
||||
|
@ -2497,7 +2505,6 @@ Program.prototype.text = function(text, attr) {
|
|||
// NOTE: sun-color may not allow multiple params for SGR.
|
||||
Program.prototype._attr = function(param, val) {
|
||||
var self = this
|
||||
, param
|
||||
, parts
|
||||
, color
|
||||
, m;
|
||||
|
@ -2557,7 +2564,6 @@ Program.prototype._attr = function(param, val) {
|
|||
return val === false
|
||||
? '\x1b[27m'
|
||||
: '\x1b[7m';
|
||||
break;
|
||||
case 'invisible':
|
||||
return val === false
|
||||
? '\x1b[28m'
|
||||
|
@ -2952,7 +2958,7 @@ Program.prototype.charPosAbsolute = function(param) {
|
|||
if (this.tput) {
|
||||
return this.put.hpa.apply(this.put, arguments);
|
||||
}
|
||||
var param = slice.call(arguments).join(';');
|
||||
param = slice.call(arguments).join(';');
|
||||
return this._write('\x1b[' + (param || '') + '`');
|
||||
};
|
||||
|
||||
|
@ -3020,7 +3026,7 @@ Program.prototype.linePosAbsolute = function(param) {
|
|||
if (this.tput) {
|
||||
return this.put.vpa.apply(this.put, arguments);
|
||||
}
|
||||
var param = slice.call(arguments).join(';');
|
||||
param = slice.call(arguments).join(';');
|
||||
return this._write('\x1b[' + (param || '') + 'd');
|
||||
};
|
||||
|
||||
|
@ -3886,7 +3892,7 @@ Program.prototype.setAttrInRectangle = function() {
|
|||
// CSI ? Pm s
|
||||
// Save DEC Private Mode Values. Ps values are the same as for
|
||||
// DECSET.
|
||||
Program.prototype.savePrivateValues = function(params) {
|
||||
Program.prototype.savePrivateValues = function() {
|
||||
return this._write('\x1b[?' + slice.call(arguments).join(';') + 's');
|
||||
};
|
||||
|
||||
|
@ -3958,7 +3964,7 @@ Program.prototype.getWindowSize = function(callback) {
|
|||
// Ps denotes the attributes to reverse, i.e., 1, 4, 5, 7.
|
||||
// NOTE: xterm doesn't enable this code by default.
|
||||
Program.prototype.decrara =
|
||||
Program.prototype.reverseAttrInRectangle = function(params) {
|
||||
Program.prototype.reverseAttrInRectangle = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '$t');
|
||||
};
|
||||
|
||||
|
@ -3971,7 +3977,7 @@ Program.prototype.reverseAttrInRectangle = function(params) {
|
|||
// Ps = 3 -> Query window/icon labels using UTF-8. (See dis-
|
||||
// cussion of "Title Modes")
|
||||
// XXX VTE bizarelly echos this:
|
||||
Program.prototype.setTitleModeFeature = function(params) {
|
||||
Program.prototype.setTitleModeFeature = function() {
|
||||
return this._twrite('\x1b[>' + slice.call(arguments).join(';') + 't');
|
||||
};
|
||||
|
||||
|
@ -3981,7 +3987,7 @@ Program.prototype.setTitleModeFeature = function(params) {
|
|||
// Ps = 2 , 3 or 4 -> low.
|
||||
// Ps = 5 , 6 , 7 , or 8 -> high.
|
||||
Program.prototype.decswbv =
|
||||
Program.prototype.setWarningBellVolume = function(params) {
|
||||
Program.prototype.setWarningBellVolume = function(param) {
|
||||
return this._write('\x1b[' + (param || '') + ' t');
|
||||
};
|
||||
|
||||
|
@ -3991,7 +3997,7 @@ Program.prototype.setWarningBellVolume = function(params) {
|
|||
// Ps = 2 , 3 or 4 -> low.
|
||||
// Ps = 0 , 5 , 6 , 7 , or 8 -> high.
|
||||
Program.prototype.decsmbv =
|
||||
Program.prototype.setMarginBellVolume = function(params) {
|
||||
Program.prototype.setMarginBellVolume = function(param) {
|
||||
return this._write('\x1b[' + (param || '') + ' u');
|
||||
};
|
||||
|
||||
|
@ -4003,7 +4009,7 @@ Program.prototype.setMarginBellVolume = function(params) {
|
|||
// Pp denotes the target page.
|
||||
// NOTE: xterm doesn't enable this code by default.
|
||||
Program.prototype.deccra =
|
||||
Program.prototype.copyRectangle = function(params) {
|
||||
Program.prototype.copyRectangle = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '$v');
|
||||
};
|
||||
|
||||
|
@ -4019,7 +4025,7 @@ Program.prototype.copyRectangle = function(params) {
|
|||
// ted, any locator motion will be reported. DECELR always can-
|
||||
// cels any prevous rectangle definition.
|
||||
Program.prototype.decefr =
|
||||
Program.prototype.enableFilterRectangle = function(params) {
|
||||
Program.prototype.enableFilterRectangle = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '\'w');
|
||||
};
|
||||
|
||||
|
@ -4035,7 +4041,7 @@ Program.prototype.enableFilterRectangle = function(params) {
|
|||
// Pn = 1 <- clock multiplier.
|
||||
// Pn = 0 <- STP flags.
|
||||
Program.prototype.decreqtparm =
|
||||
Program.prototype.requestParameters = function(params) {
|
||||
Program.prototype.requestParameters = function(param) {
|
||||
return this._write('\x1b[' + (param || 0) + 'x');
|
||||
};
|
||||
|
||||
|
@ -4044,7 +4050,7 @@ Program.prototype.requestParameters = function(params) {
|
|||
// Ps = 1 -> from start to end position, wrapped.
|
||||
// Ps = 2 -> rectangle (exact).
|
||||
Program.prototype.decsace =
|
||||
Program.prototype.selectChangeExtent = function(params) {
|
||||
Program.prototype.selectChangeExtent = function(param) {
|
||||
return this._write('\x1b[' + (param || 0) + 'x');
|
||||
};
|
||||
|
||||
|
@ -4054,7 +4060,7 @@ Program.prototype.selectChangeExtent = function(params) {
|
|||
// Pt; Pl; Pb; Pr denotes the rectangle.
|
||||
// NOTE: xterm doesn't enable this code by default.
|
||||
Program.prototype.decfra =
|
||||
Program.prototype.fillRectangle = function(params) {
|
||||
Program.prototype.fillRectangle = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '$x');
|
||||
};
|
||||
|
||||
|
@ -4071,7 +4077,7 @@ Program.prototype.fillRectangle = function(params) {
|
|||
// Pu = 1 <- device physical pixels.
|
||||
// Pu = 2 <- character cells.
|
||||
Program.prototype.decelr =
|
||||
Program.prototype.enableLocatorReporting = function(params) {
|
||||
Program.prototype.enableLocatorReporting = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '\'z');
|
||||
};
|
||||
|
||||
|
@ -4080,7 +4086,7 @@ Program.prototype.enableLocatorReporting = function(params) {
|
|||
// Pt; Pl; Pb; Pr denotes the rectangle.
|
||||
// NOTE: xterm doesn't enable this code by default.
|
||||
Program.prototype.decera =
|
||||
Program.prototype.eraseRectangle = function(params) {
|
||||
Program.prototype.eraseRectangle = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '$z');
|
||||
};
|
||||
|
||||
|
@ -4096,7 +4102,7 @@ Program.prototype.eraseRectangle = function(params) {
|
|||
// Ps = 3 -> report button up transitions.
|
||||
// Ps = 4 -> do not report button up transitions.
|
||||
Program.prototype.decsle =
|
||||
Program.prototype.setLocatorEvents = function(params) {
|
||||
Program.prototype.setLocatorEvents = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '\'{');
|
||||
};
|
||||
|
||||
|
@ -4104,7 +4110,7 @@ Program.prototype.setLocatorEvents = function(params) {
|
|||
// Selective Erase Rectangular Area (DECSERA), VT400 and up.
|
||||
// Pt; Pl; Pb; Pr denotes the rectangle.
|
||||
Program.prototype.decsera =
|
||||
Program.prototype.selectiveEraseRectangle = function(params) {
|
||||
Program.prototype.selectiveEraseRectangle = function() {
|
||||
return this._write('\x1b[' + slice.call(arguments).join(';') + '${');
|
||||
};
|
||||
|
||||
|
@ -4151,13 +4157,13 @@ Program.prototype.selectiveEraseRectangle = function(params) {
|
|||
Program.prototype.decrqlp =
|
||||
Program.prototype.req_mouse_pos =
|
||||
Program.prototype.reqmp =
|
||||
Program.prototype.requestLocatorPosition = function(params, callback) {
|
||||
Program.prototype.requestLocatorPosition = function(param, callback) {
|
||||
// See also:
|
||||
// get_mouse / getm / Gm
|
||||
// mouse_info / minfo / Mi
|
||||
// Correct for tput?
|
||||
if (this.has('req_mouse_pos')) {
|
||||
var code = this.tput.req_mouse_pos.apply(this.tput, params);
|
||||
var code = this.tput.req_mouse_pos(param);
|
||||
return this.response('locator-position', code, callback);
|
||||
}
|
||||
return this.response('locator-position',
|
||||
|
@ -4181,6 +4187,7 @@ Program.prototype.deleteColumns = function() {
|
|||
};
|
||||
|
||||
Program.prototype.out = function(name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
this.ret = true;
|
||||
var out = this[name].apply(this, args);
|
||||
this.ret = false;
|
||||
|
@ -4234,7 +4241,7 @@ Program.prototype.pause = function(callback) {
|
|||
};
|
||||
};
|
||||
|
||||
Program.prototype.resume = function(callback) {
|
||||
Program.prototype.resume = function() {
|
||||
if (this._resume) return this._resume();
|
||||
};
|
||||
|
||||
|
@ -4252,7 +4259,7 @@ function unshiftEvent(obj, event, listener) {
|
|||
listeners.forEach(function(listener) {
|
||||
obj.on(event, listener);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function merge(out) {
|
||||
slice.call(arguments, 1).forEach(function(obj) {
|
||||
|
|
45
lib/tput.js
45
lib/tput.js
|
@ -61,7 +61,7 @@ function Tput(options) {
|
|||
if (options.terminal || options.term) {
|
||||
this.setup();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Tput.prototype.setup = function() {
|
||||
try {
|
||||
|
@ -145,11 +145,12 @@ Tput.ipaths = [
|
|||
];
|
||||
|
||||
Tput.prototype.readTerminfo = function(term) {
|
||||
var term = term || this.terminal
|
||||
, data
|
||||
var data
|
||||
, file
|
||||
, info;
|
||||
|
||||
term = term || this.terminal;
|
||||
|
||||
file = path.normalize(this._prefix(term));
|
||||
data = fs.readFileSync(file);
|
||||
info = this.parseTerminfo(data, file);
|
||||
|
@ -199,7 +200,6 @@ Tput.prototype._tprefix = function(prefix, term, soft) {
|
|||
|
||||
var file
|
||||
, dir
|
||||
, ch
|
||||
, i
|
||||
, sdiff
|
||||
, sfile
|
||||
|
@ -718,8 +718,7 @@ Tput.prototype.inject = function(info) {
|
|||
// ~/ncurses/ncurses/tinfo/lib_tparm.c
|
||||
// ~/ncurses/ncurses/tinfo/comp_scan.c
|
||||
Tput.prototype._compile = function(info, key, str) {
|
||||
var self = this
|
||||
, v;
|
||||
var v;
|
||||
|
||||
this._debug('Compiling %s: %s', key, JSON.stringify(str));
|
||||
|
||||
|
@ -1165,9 +1164,10 @@ Tput.prototype._compile = function(info, key, str) {
|
|||
|
||||
// See: ~/ncurses/ncurses/tinfo/lib_tputs.c
|
||||
Tput.prototype._print = function(code, print, done) {
|
||||
var print = print || write
|
||||
, done = done || noop
|
||||
, xon = !this.bools.needs_xon_xoff || this.bools.xon_xoff;
|
||||
var xon = !this.bools.needs_xon_xoff || this.bools.xon_xoff;
|
||||
|
||||
print = print || write;
|
||||
done = done || noop;
|
||||
|
||||
if (!this.padding) {
|
||||
print(code);
|
||||
|
@ -1185,8 +1185,8 @@ Tput.prototype._print = function(code, print, done) {
|
|||
var part = parts[i++]
|
||||
, padding = /^\$<([\d.]+)([*\/]{0,2})>/.exec(part)
|
||||
, amount
|
||||
, suffix
|
||||
, affect;
|
||||
, suffix;
|
||||
// , affect;
|
||||
|
||||
if (!padding) {
|
||||
print(part);
|
||||
|
@ -1259,12 +1259,12 @@ Tput.cpaths = [
|
|||
|
||||
Tput.prototype.readTermcap = function(term) {
|
||||
var self = this
|
||||
, term = term || this.terminal
|
||||
, terms
|
||||
, term_
|
||||
, root
|
||||
, paths
|
||||
, i;
|
||||
, paths;
|
||||
|
||||
term = term || this.terminal;
|
||||
|
||||
// Termcap has a bunch of terminals usually stored in one file/string,
|
||||
// so we need to find the one containing our desired terminal.
|
||||
|
@ -2069,8 +2069,8 @@ Tput.prototype.detectBrokenACS = function(info) {
|
|||
}
|
||||
|
||||
// If the terminal supports unicode, we don't need ACS.
|
||||
if (info.numbers['U8'] >= 0) {
|
||||
return !!info.numbers['U8'];
|
||||
if (info.numbers.U8 >= 0) {
|
||||
return !!info.numbers.U8;
|
||||
}
|
||||
|
||||
// The linux console is just broken for some reason.
|
||||
|
@ -2088,7 +2088,7 @@ Tput.prototype.detectBrokenACS = function(info) {
|
|||
|
||||
// screen termcap is bugged?
|
||||
if (this.termcap
|
||||
&& info.name.indexOf('screen') == 0
|
||||
&& info.name.indexOf('screen') === 0
|
||||
&& process.env.TERMCAP
|
||||
&& ~process.env.TERMCAP.indexOf('screen')
|
||||
&& ~process.env.TERMCAP.indexOf('hhII00')) {
|
||||
|
@ -2116,15 +2116,15 @@ Tput.prototype.detectPCRomSet = function(info) {
|
|||
return false;
|
||||
};
|
||||
|
||||
Tput.prototype.detectMagicCookie = function(info) {
|
||||
Tput.prototype.detectMagicCookie = function() {
|
||||
return process.env.NCURSES_NO_MAGIC_COOKIE == null;
|
||||
};
|
||||
|
||||
Tput.prototype.detectPadding = function(info) {
|
||||
Tput.prototype.detectPadding = function() {
|
||||
return process.env.NCURSES_NO_PADDING == null;
|
||||
};
|
||||
|
||||
Tput.prototype.detectSetbuf = function(info) {
|
||||
Tput.prototype.detectSetbuf = function() {
|
||||
return process.env.NCURSES_NO_SETBUF == null;
|
||||
};
|
||||
|
||||
|
@ -2388,8 +2388,9 @@ Object.keys(Tput.alias).forEach(function(key) {
|
|||
});
|
||||
|
||||
Tput.prototype.has = function(name) {
|
||||
var name = Tput.aliasMap[name]
|
||||
, val = this.all[name];
|
||||
name = Tput.aliasMap[name];
|
||||
|
||||
var val = this.all[name];
|
||||
|
||||
if (!name) return false;
|
||||
|
||||
|
|
180
lib/unicode.js
180
lib/unicode.js
|
@ -142,9 +142,9 @@ exports.charWidth = function(str, i) {
|
|||
// check for double-wide
|
||||
// if (point >= 0x1100
|
||||
// && (point <= 0x115f // Hangul Jamo init. consonants
|
||||
// || point == 0x2329 || point == 0x232a
|
||||
// || point === 0x2329 || point === 0x232a
|
||||
// || (point >= 0x2e80 && point <= 0xa4cf
|
||||
// && point != 0x303f) // CJK ... Yi
|
||||
// && point !== 0x303f) // CJK ... Yi
|
||||
// || (point >= 0xac00 && point <= 0xd7a3) // Hangul Syllables
|
||||
// || (point >= 0xf900 && point <= 0xfaff) // CJK Compatibility Ideographs
|
||||
// || (point >= 0xfe10 && point <= 0xfe19) // Vertical forms
|
||||
|
@ -157,7 +157,7 @@ exports.charWidth = function(str, i) {
|
|||
// }
|
||||
|
||||
// check for double-wide
|
||||
if ((0x3000 == point)
|
||||
if ((0x3000 === point)
|
||||
|| (0xFF01 <= point && point <= 0xFF60)
|
||||
|| (0xFFE0 <= point && point <= 0xFFE6)) {
|
||||
return 2;
|
||||
|
@ -208,129 +208,129 @@ exports.charWidth = function(str, i) {
|
|||
// http://www.unicode.org/reports/tr11/
|
||||
// http://www.unicode.org/reports/tr11/#Ambiguous
|
||||
if (process.env.NCURSES_CJK_WIDTH) {
|
||||
if ((0x00A1 == point)
|
||||
|| (0x00A4 == point)
|
||||
if ((0x00A1 === point)
|
||||
|| (0x00A4 === point)
|
||||
|| (0x00A7 <= point && point <= 0x00A8)
|
||||
|| (0x00AA == point)
|
||||
|| (0x00AA === point)
|
||||
|| (0x00AD <= point && point <= 0x00AE)
|
||||
|| (0x00B0 <= point && point <= 0x00B4)
|
||||
|| (0x00B6 <= point && point <= 0x00BA)
|
||||
|| (0x00BC <= point && point <= 0x00BF)
|
||||
|| (0x00C6 == point)
|
||||
|| (0x00D0 == point)
|
||||
|| (0x00C6 === point)
|
||||
|| (0x00D0 === point)
|
||||
|| (0x00D7 <= point && point <= 0x00D8)
|
||||
|| (0x00DE <= point && point <= 0x00E1)
|
||||
|| (0x00E6 == point)
|
||||
|| (0x00E6 === point)
|
||||
|| (0x00E8 <= point && point <= 0x00EA)
|
||||
|| (0x00EC <= point && point <= 0x00ED)
|
||||
|| (0x00F0 == point)
|
||||
|| (0x00F0 === point)
|
||||
|| (0x00F2 <= point && point <= 0x00F3)
|
||||
|| (0x00F7 <= point && point <= 0x00FA)
|
||||
|| (0x00FC == point)
|
||||
|| (0x00FE == point)
|
||||
|| (0x0101 == point)
|
||||
|| (0x0111 == point)
|
||||
|| (0x0113 == point)
|
||||
|| (0x011B == point)
|
||||
|| (0x00FC === point)
|
||||
|| (0x00FE === point)
|
||||
|| (0x0101 === point)
|
||||
|| (0x0111 === point)
|
||||
|| (0x0113 === point)
|
||||
|| (0x011B === point)
|
||||
|| (0x0126 <= point && point <= 0x0127)
|
||||
|| (0x012B == point)
|
||||
|| (0x012B === point)
|
||||
|| (0x0131 <= point && point <= 0x0133)
|
||||
|| (0x0138 == point)
|
||||
|| (0x0138 === point)
|
||||
|| (0x013F <= point && point <= 0x0142)
|
||||
|| (0x0144 == point)
|
||||
|| (0x0144 === point)
|
||||
|| (0x0148 <= point && point <= 0x014B)
|
||||
|| (0x014D == point)
|
||||
|| (0x014D === point)
|
||||
|| (0x0152 <= point && point <= 0x0153)
|
||||
|| (0x0166 <= point && point <= 0x0167)
|
||||
|| (0x016B == point)
|
||||
|| (0x01CE == point)
|
||||
|| (0x01D0 == point)
|
||||
|| (0x01D2 == point)
|
||||
|| (0x01D4 == point)
|
||||
|| (0x01D6 == point)
|
||||
|| (0x01D8 == point)
|
||||
|| (0x01DA == point)
|
||||
|| (0x01DC == point)
|
||||
|| (0x0251 == point)
|
||||
|| (0x0261 == point)
|
||||
|| (0x02C4 == point)
|
||||
|| (0x02C7 == point)
|
||||
|| (0x016B === point)
|
||||
|| (0x01CE === point)
|
||||
|| (0x01D0 === point)
|
||||
|| (0x01D2 === point)
|
||||
|| (0x01D4 === point)
|
||||
|| (0x01D6 === point)
|
||||
|| (0x01D8 === point)
|
||||
|| (0x01DA === point)
|
||||
|| (0x01DC === point)
|
||||
|| (0x0251 === point)
|
||||
|| (0x0261 === point)
|
||||
|| (0x02C4 === point)
|
||||
|| (0x02C7 === point)
|
||||
|| (0x02C9 <= point && point <= 0x02CB)
|
||||
|| (0x02CD == point)
|
||||
|| (0x02D0 == point)
|
||||
|| (0x02CD === point)
|
||||
|| (0x02D0 === point)
|
||||
|| (0x02D8 <= point && point <= 0x02DB)
|
||||
|| (0x02DD == point)
|
||||
|| (0x02DF == point)
|
||||
|| (0x02DD === point)
|
||||
|| (0x02DF === point)
|
||||
|| (0x0300 <= point && point <= 0x036F)
|
||||
|| (0x0391 <= point && point <= 0x03A1)
|
||||
|| (0x03A3 <= point && point <= 0x03A9)
|
||||
|| (0x03B1 <= point && point <= 0x03C1)
|
||||
|| (0x03C3 <= point && point <= 0x03C9)
|
||||
|| (0x0401 == point)
|
||||
|| (0x0401 === point)
|
||||
|| (0x0410 <= point && point <= 0x044F)
|
||||
|| (0x0451 == point)
|
||||
|| (0x2010 == point)
|
||||
|| (0x0451 === point)
|
||||
|| (0x2010 === point)
|
||||
|| (0x2013 <= point && point <= 0x2016)
|
||||
|| (0x2018 <= point && point <= 0x2019)
|
||||
|| (0x201C <= point && point <= 0x201D)
|
||||
|| (0x2020 <= point && point <= 0x2022)
|
||||
|| (0x2024 <= point && point <= 0x2027)
|
||||
|| (0x2030 == point)
|
||||
|| (0x2030 === point)
|
||||
|| (0x2032 <= point && point <= 0x2033)
|
||||
|| (0x2035 == point)
|
||||
|| (0x203B == point)
|
||||
|| (0x203E == point)
|
||||
|| (0x2074 == point)
|
||||
|| (0x207F == point)
|
||||
|| (0x2035 === point)
|
||||
|| (0x203B === point)
|
||||
|| (0x203E === point)
|
||||
|| (0x2074 === point)
|
||||
|| (0x207F === point)
|
||||
|| (0x2081 <= point && point <= 0x2084)
|
||||
|| (0x20AC == point)
|
||||
|| (0x2103 == point)
|
||||
|| (0x2105 == point)
|
||||
|| (0x2109 == point)
|
||||
|| (0x2113 == point)
|
||||
|| (0x2116 == point)
|
||||
|| (0x20AC === point)
|
||||
|| (0x2103 === point)
|
||||
|| (0x2105 === point)
|
||||
|| (0x2109 === point)
|
||||
|| (0x2113 === point)
|
||||
|| (0x2116 === point)
|
||||
|| (0x2121 <= point && point <= 0x2122)
|
||||
|| (0x2126 == point)
|
||||
|| (0x212B == point)
|
||||
|| (0x2126 === point)
|
||||
|| (0x212B === point)
|
||||
|| (0x2153 <= point && point <= 0x2154)
|
||||
|| (0x215B <= point && point <= 0x215E)
|
||||
|| (0x2160 <= point && point <= 0x216B)
|
||||
|| (0x2170 <= point && point <= 0x2179)
|
||||
|| (0x2189 == point)
|
||||
|| (0x2189 === point)
|
||||
|| (0x2190 <= point && point <= 0x2199)
|
||||
|| (0x21B8 <= point && point <= 0x21B9)
|
||||
|| (0x21D2 == point)
|
||||
|| (0x21D4 == point)
|
||||
|| (0x21E7 == point)
|
||||
|| (0x2200 == point)
|
||||
|| (0x21D2 === point)
|
||||
|| (0x21D4 === point)
|
||||
|| (0x21E7 === point)
|
||||
|| (0x2200 === point)
|
||||
|| (0x2202 <= point && point <= 0x2203)
|
||||
|| (0x2207 <= point && point <= 0x2208)
|
||||
|| (0x220B == point)
|
||||
|| (0x220F == point)
|
||||
|| (0x2211 == point)
|
||||
|| (0x2215 == point)
|
||||
|| (0x221A == point)
|
||||
|| (0x220B === point)
|
||||
|| (0x220F === point)
|
||||
|| (0x2211 === point)
|
||||
|| (0x2215 === point)
|
||||
|| (0x221A === point)
|
||||
|| (0x221D <= point && point <= 0x2220)
|
||||
|| (0x2223 == point)
|
||||
|| (0x2225 == point)
|
||||
|| (0x2223 === point)
|
||||
|| (0x2225 === point)
|
||||
|| (0x2227 <= point && point <= 0x222C)
|
||||
|| (0x222E == point)
|
||||
|| (0x222E === point)
|
||||
|| (0x2234 <= point && point <= 0x2237)
|
||||
|| (0x223C <= point && point <= 0x223D)
|
||||
|| (0x2248 == point)
|
||||
|| (0x224C == point)
|
||||
|| (0x2252 == point)
|
||||
|| (0x2248 === point)
|
||||
|| (0x224C === point)
|
||||
|| (0x2252 === point)
|
||||
|| (0x2260 <= point && point <= 0x2261)
|
||||
|| (0x2264 <= point && point <= 0x2267)
|
||||
|| (0x226A <= point && point <= 0x226B)
|
||||
|| (0x226E <= point && point <= 0x226F)
|
||||
|| (0x2282 <= point && point <= 0x2283)
|
||||
|| (0x2286 <= point && point <= 0x2287)
|
||||
|| (0x2295 == point)
|
||||
|| (0x2299 == point)
|
||||
|| (0x22A5 == point)
|
||||
|| (0x22BF == point)
|
||||
|| (0x2312 == point)
|
||||
|| (0x2295 === point)
|
||||
|| (0x2299 === point)
|
||||
|| (0x22A5 === point)
|
||||
|| (0x22BF === point)
|
||||
|| (0x2312 === point)
|
||||
|| (0x2460 <= point && point <= 0x24E9)
|
||||
|| (0x24EB <= point && point <= 0x254B)
|
||||
|| (0x2550 <= point && point <= 0x2573)
|
||||
|
@ -343,37 +343,37 @@ exports.charWidth = function(str, i) {
|
|||
|| (0x25BC <= point && point <= 0x25BD)
|
||||
|| (0x25C0 <= point && point <= 0x25C1)
|
||||
|| (0x25C6 <= point && point <= 0x25C8)
|
||||
|| (0x25CB == point)
|
||||
|| (0x25CB === point)
|
||||
|| (0x25CE <= point && point <= 0x25D1)
|
||||
|| (0x25E2 <= point && point <= 0x25E5)
|
||||
|| (0x25EF == point)
|
||||
|| (0x25EF === point)
|
||||
|| (0x2605 <= point && point <= 0x2606)
|
||||
|| (0x2609 == point)
|
||||
|| (0x2609 === point)
|
||||
|| (0x260E <= point && point <= 0x260F)
|
||||
|| (0x2614 <= point && point <= 0x2615)
|
||||
|| (0x261C == point)
|
||||
|| (0x261E == point)
|
||||
|| (0x2640 == point)
|
||||
|| (0x2642 == point)
|
||||
|| (0x261C === point)
|
||||
|| (0x261E === point)
|
||||
|| (0x2640 === point)
|
||||
|| (0x2642 === point)
|
||||
|| (0x2660 <= point && point <= 0x2661)
|
||||
|| (0x2663 <= point && point <= 0x2665)
|
||||
|| (0x2667 <= point && point <= 0x266A)
|
||||
|| (0x266C <= point && point <= 0x266D)
|
||||
|| (0x266F == point)
|
||||
|| (0x266F === point)
|
||||
|| (0x269E <= point && point <= 0x269F)
|
||||
|| (0x26BE <= point && point <= 0x26BF)
|
||||
|| (0x26C4 <= point && point <= 0x26CD)
|
||||
|| (0x26CF <= point && point <= 0x26E1)
|
||||
|| (0x26E3 == point)
|
||||
|| (0x26E3 === point)
|
||||
|| (0x26E8 <= point && point <= 0x26FF)
|
||||
|| (0x273D == point)
|
||||
|| (0x2757 == point)
|
||||
|| (0x273D === point)
|
||||
|| (0x2757 === point)
|
||||
|| (0x2776 <= point && point <= 0x277F)
|
||||
|| (0x2B55 <= point && point <= 0x2B59)
|
||||
|| (0x3248 <= point && point <= 0x324F)
|
||||
|| (0xE000 <= point && point <= 0xF8FF)
|
||||
|| (0xFE00 <= point && point <= 0xFE0F)
|
||||
|| (0xFFFD == point)
|
||||
|| (0xFFFD === point)
|
||||
|| (0x1F100 <= point && point <= 0x1F10A)
|
||||
|| (0x1F110 <= point && point <= 0x1F12D)
|
||||
|| (0x1F130 <= point && point <= 0x1F169)
|
||||
|
@ -484,7 +484,7 @@ exports.codePointAt = function(str, position) {
|
|||
var size = string.length;
|
||||
// `ToInteger`
|
||||
var index = position ? Number(position) : 0;
|
||||
if (index != index) { // better `isNaN`
|
||||
if (index !== index) { // better `isNaN`
|
||||
index = 0;
|
||||
}
|
||||
// Account for out-of-bounds indices:
|
||||
|
@ -541,7 +541,7 @@ exports.fromCodePoint = function() {
|
|||
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
||||
codePoint < 0 || // not a valid Unicode code point
|
||||
codePoint > 0x10FFFF || // not a valid Unicode code point
|
||||
floor(codePoint) != codePoint // not an integer
|
||||
floor(codePoint) !== codePoint // not an integer
|
||||
) {
|
||||
throw RangeError('Invalid code point: ' + codePoint);
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ exports.fromCodePoint = function() {
|
|||
lowSurrogate = (codePoint % 0x400) + 0xDC00;
|
||||
codeUnits.push(highSurrogate, lowSurrogate);
|
||||
}
|
||||
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
|
||||
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
||||
result += stringFromCharCode.apply(null, codeUnits);
|
||||
codeUnits.length = 0;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,8 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var cp = require('child_process')
|
||||
, path = require('path')
|
||||
, fs = require('fs');
|
||||
var cp = require('child_process');
|
||||
|
||||
var helpers = require('../helpers');
|
||||
var colors = require('../colors');
|
||||
|
||||
var Node = require('./node');
|
||||
|
@ -148,8 +145,6 @@ ANSIImage.prototype.clearImage = function() {
|
|||
};
|
||||
|
||||
ANSIImage.prototype.render = function() {
|
||||
var self = this;
|
||||
|
||||
var coords = this._render();
|
||||
if (!coords) return;
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
var fs = require('fs');
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Element = require('./element');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Input = require('./input');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Input = require('./input');
|
||||
|
||||
|
@ -45,7 +43,7 @@ function Checkbox(options) {
|
|||
});
|
||||
}
|
||||
|
||||
this.on('focus', function(old) {
|
||||
this.on('focus', function() {
|
||||
var lpos = self.lpos;
|
||||
if (!lpos) return;
|
||||
self.screen.program.lsaveCursor('checkbox');
|
||||
|
|
|
@ -589,7 +589,6 @@ Element.prototype._wrapContent = function(content, width) {
|
|||
, margin = 0
|
||||
, rtof = []
|
||||
, ftor = []
|
||||
, fake = []
|
||||
, out = []
|
||||
, no = 0
|
||||
, line
|
||||
|
@ -860,16 +859,16 @@ Element.prototype.disableDrag = function() {
|
|||
return this._draggable = false;
|
||||
};
|
||||
|
||||
Element.prototype.key = function(key, listener) {
|
||||
Element.prototype.key = function() {
|
||||
return this.screen.program.key.apply(this, arguments);
|
||||
};
|
||||
|
||||
Element.prototype.onceKey = function(key, listener) {
|
||||
Element.prototype.onceKey = function() {
|
||||
return this.screen.program.onceKey.apply(this, arguments);
|
||||
};
|
||||
|
||||
Element.prototype.unkey =
|
||||
Element.prototype.removeKey = function(key, listener) {
|
||||
Element.prototype.removeKey = function() {
|
||||
return this.screen.program.unkey.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
@ -886,7 +885,7 @@ Element.prototype.setIndex = function(index) {
|
|||
var i = this.parent.children.indexOf(this);
|
||||
if (!~i) return;
|
||||
|
||||
var item = this.parent.children.splice(i, 1)[0]
|
||||
var item = this.parent.children.splice(i, 1)[0];
|
||||
this.parent.children.splice(index, 0, item);
|
||||
};
|
||||
|
||||
|
@ -962,7 +961,6 @@ Element.prototype.setLabel = function(options) {
|
|||
}
|
||||
|
||||
var reposition = function() {
|
||||
var visible = self.height - self.iheight;
|
||||
self._label.rtop = (self.childBase || 0) - self.itop;
|
||||
if (!self.screen.autoPadding) {
|
||||
self._label.rtop = (self.childBase || 0);
|
||||
|
@ -992,8 +990,6 @@ Element.prototype.removeLabel = function() {
|
|||
};
|
||||
|
||||
Element.prototype.setHover = function(options) {
|
||||
var self = this;
|
||||
|
||||
if (typeof options === 'string') {
|
||||
options = { text: options };
|
||||
}
|
||||
|
@ -1605,7 +1601,7 @@ Element.prototype._getShrinkBox = function(xi, xl, yi, yl, get) {
|
|||
return { xi: xi, xl: xl, yi: yi, yl: yl };
|
||||
};
|
||||
|
||||
Element.prototype._getShrinkContent = function(xi, xl, yi, yl, get) {
|
||||
Element.prototype._getShrinkContent = function(xi, xl, yi, yl) {
|
||||
var h = this._clines.length
|
||||
, w = this._clines.mwidth || 1;
|
||||
|
||||
|
@ -2429,12 +2425,16 @@ Element.prototype.deleteLine = function(i, n) {
|
|||
|
||||
diff = start - this._clines.length;
|
||||
|
||||
// XXX clearPos() without diff statement?
|
||||
var height = 0;
|
||||
|
||||
if (diff > 0) {
|
||||
var pos = this._getCoords();
|
||||
if (!pos) return;
|
||||
|
||||
var height = pos.yl - pos.yi - this.iheight
|
||||
, base = this.childBase || 0
|
||||
height = pos.yl - pos.yi - this.iheight;
|
||||
|
||||
var base = this.childBase || 0
|
||||
, visible = real >= base && real - base < height;
|
||||
|
||||
if (pos && visible && this.screen.cleanSides(this)) {
|
||||
|
@ -2471,9 +2471,10 @@ Element.prototype.deleteTop = function(n) {
|
|||
Element.prototype.deleteBottom = function(n) {
|
||||
var h = (this.childBase || 0) + this.height - 1 - this.iheight
|
||||
, i = Math.min(h, this._clines.length - 1)
|
||||
, n = n || 1
|
||||
, fake = this._clines.rtof[i];
|
||||
|
||||
n = n || 1;
|
||||
|
||||
return this.deleteLine(fake - (n - 1), n);
|
||||
};
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -165,8 +163,7 @@ Form.prototype.focusLast = function() {
|
|||
};
|
||||
|
||||
Form.prototype.submit = function() {
|
||||
var self = this
|
||||
, out = {};
|
||||
var out = {};
|
||||
|
||||
this.children.forEach(function fn(el) {
|
||||
if (el.value != null) {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -18,8 +16,6 @@ var Box = require('./box');
|
|||
*/
|
||||
|
||||
function Image(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Image(options);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Element = require('./element');
|
||||
|
||||
|
@ -18,8 +16,6 @@ var Element = require('./element');
|
|||
*/
|
||||
|
||||
function Layout(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Layout(options);
|
||||
}
|
||||
|
@ -80,9 +76,7 @@ Layout.prototype.renderer = function(coords) {
|
|||
var width = coords.xl - coords.xi
|
||||
, height = coords.yl - coords.yi
|
||||
, xi = coords.xi
|
||||
, xl = coords.xl
|
||||
, yi = coords.yi
|
||||
, yl = coords.yl;
|
||||
, yi = coords.yi;
|
||||
|
||||
// The current row offset in cells (which row are we on?)
|
||||
var rowOffset = 0;
|
||||
|
@ -175,8 +169,6 @@ Layout.prototype.renderer = function(coords) {
|
|||
};
|
||||
|
||||
Layout.prototype.render = function() {
|
||||
var self = this;
|
||||
|
||||
this._emit('prerender');
|
||||
|
||||
var coords = this._renderCoords();
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -18,8 +16,6 @@ var Box = require('./box');
|
|||
*/
|
||||
|
||||
function Line(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Line(options);
|
||||
}
|
||||
|
|
|
@ -92,11 +92,11 @@ function List(options) {
|
|||
|
||||
if (options.mouse) {
|
||||
this.screen._listenMouse(this);
|
||||
this.on('element wheeldown', function(el, data) {
|
||||
this.on('element wheeldown', function() {
|
||||
self.select(self.selected + 2);
|
||||
self.screen.render();
|
||||
});
|
||||
this.on('element wheelup', function(el, data) {
|
||||
this.on('element wheelup', function() {
|
||||
self.select(self.selected - 2);
|
||||
self.screen.render();
|
||||
});
|
||||
|
@ -274,7 +274,7 @@ List.prototype.createItem = function(content) {
|
|||
var item = new Box(options);
|
||||
|
||||
if (this.mouse) {
|
||||
item.on('click', function(data) {
|
||||
item.on('click', function() {
|
||||
self.focus();
|
||||
if (self.items[self.selected] === item) {
|
||||
self.emit('action', item, self.selected);
|
||||
|
@ -294,8 +294,6 @@ List.prototype.createItem = function(content) {
|
|||
List.prototype.add =
|
||||
List.prototype.addItem =
|
||||
List.prototype.appendItem = function(content) {
|
||||
var self = this;
|
||||
|
||||
content = typeof content === 'string' ? content : content.getContent();
|
||||
|
||||
var item = this.createItem(content);
|
||||
|
@ -370,12 +368,13 @@ List.prototype.clearItems = function() {
|
|||
};
|
||||
|
||||
List.prototype.setItems = function(items) {
|
||||
var items = items.slice()
|
||||
, original = this.items.slice()
|
||||
var original = this.items.slice()
|
||||
, selected = this.selected
|
||||
, sel = this.ritems[this.selected]
|
||||
, i = 0;
|
||||
|
||||
items = items.slice();
|
||||
|
||||
this.select(0);
|
||||
|
||||
for (; i < items.length; i++) {
|
||||
|
@ -440,7 +439,8 @@ List.prototype.spliceItem = function(child, n) {
|
|||
|
||||
List.prototype.find =
|
||||
List.prototype.fuzzyFind = function(search, back) {
|
||||
var start = this.selected + (back ? -1 : 1);
|
||||
var start = this.selected + (back ? -1 : 1)
|
||||
, i;
|
||||
|
||||
if (typeof search === 'number') search += '';
|
||||
|
||||
|
@ -464,17 +464,17 @@ List.prototype.fuzzyFind = function(search, back) {
|
|||
}
|
||||
|
||||
if (!back) {
|
||||
for (var i = start; i < this.ritems.length; i++){
|
||||
for (i = start; i < this.ritems.length; i++) {
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
for (var i = 0; i < start; i++){
|
||||
for (i = 0; i < start; i++) {
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
} else {
|
||||
for (var i = start; i >= 0; i--){
|
||||
for (i = start; i >= 0; i--) {
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
for (var i = this.ritems.length - 1; i > start; i--){
|
||||
for (i = this.ritems.length - 1; i > start; i--) {
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ function Listbar(options) {
|
|||
}
|
||||
|
||||
if (options.autoCommandKeys) {
|
||||
this.onScreenEvent('keypress', function(ch, key) {
|
||||
this.onScreenEvent('keypress', function(ch) {
|
||||
if (/^[0-9]$/.test(ch)) {
|
||||
var i = +ch - 1;
|
||||
if (!~i) i = 9;
|
||||
|
@ -165,7 +165,7 @@ Listbar.prototype.appendItem = function(item, callback) {
|
|||
if (!this.parent) {
|
||||
drawn = 0;
|
||||
} else {
|
||||
drawn = prev ? prev.aleft + prev.width : 0
|
||||
drawn = prev ? prev.aleft + prev.width : 0;
|
||||
if (!this.screen.autoPadding) {
|
||||
drawn += this.ileft;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ Listbar.prototype.appendItem = function(item, callback) {
|
|||
|
||||
if (cmd.callback) {
|
||||
if (cmd.keys) {
|
||||
this.screen.key(cmd.keys, function(ch, key) {
|
||||
this.screen.key(cmd.keys, function() {
|
||||
self.emit('action', el, self.selected);
|
||||
self.emit('select', el, self.selected);
|
||||
if (el._.cmd.callback) {
|
||||
|
@ -264,7 +264,7 @@ Listbar.prototype.appendItem = function(item, callback) {
|
|||
|
||||
// XXX May be affected by new element.options.mouse option.
|
||||
if (this.mouse) {
|
||||
el.on('click', function(data) {
|
||||
el.on('click', function() {
|
||||
self.emit('action', el, self.selected);
|
||||
self.emit('select', el, self.selected);
|
||||
if (el._.cmd.callback) {
|
||||
|
@ -311,7 +311,7 @@ Listbar.prototype.select = function(offset) {
|
|||
}
|
||||
|
||||
if (!this.parent) {
|
||||
this.emit('select item', el, offset);
|
||||
this.emit('select item', this.items[offset], offset);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
var List = require('./list');
|
||||
|
@ -104,7 +102,6 @@ ListTable.prototype.setData = function(rows) {
|
|||
|
||||
this.rows.forEach(function(row, i) {
|
||||
var isHeader = i === 0;
|
||||
var isFooter = i === self.rows.length - 1;
|
||||
var text = '';
|
||||
row.forEach(function(cell, i) {
|
||||
var width = self._maxes[i];
|
||||
|
@ -177,17 +174,14 @@ ListTable.prototype.render = function() {
|
|||
|
||||
var lines = this.screen.lines
|
||||
, xi = coords.xi
|
||||
, xl = coords.xl
|
||||
, yi = coords.yi
|
||||
, yl = coords.yl
|
||||
, rx
|
||||
, ry
|
||||
, i;
|
||||
|
||||
var battr = this.sattr(this.style.border);
|
||||
|
||||
var width = coords.xl - coords.xi - this.iright
|
||||
, height = coords.yl - coords.yi - this.ibottom;
|
||||
var height = coords.yl - coords.yi - this.ibottom;
|
||||
|
||||
if (!this.border || this.options.noCellBorders) return coords;
|
||||
|
||||
|
@ -196,13 +190,14 @@ ListTable.prototype.render = function() {
|
|||
for (i = 0; i < height + 1; i++) {
|
||||
if (!lines[yi + ry]) break;
|
||||
rx = 0;
|
||||
self._maxes.slice(0, -1).forEach(function(max, i) {
|
||||
self._maxes.slice(0, -1).forEach(function(max) {
|
||||
rx += max;
|
||||
if (!lines[yi + ry][xi + rx + 1]) return;
|
||||
// center
|
||||
if (ry === 0) {
|
||||
// top
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
lines[yi + ry][xi + rx][1] = '\u252c'; // '┬'
|
||||
// XXX If we alter iheight and itop for no borders - nothing should be written here
|
||||
if (!self.border.top) {
|
||||
|
@ -211,7 +206,8 @@ ListTable.prototype.render = function() {
|
|||
lines[yi + ry].dirty = true;
|
||||
} else if (ry === height) {
|
||||
// bottom
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
lines[yi + ry][xi + rx][1] = '\u2534'; // '┴'
|
||||
// XXX If we alter iheight and ibottom for no borders - nothing should be written here
|
||||
if (!self.border.bottom) {
|
||||
|
@ -220,7 +216,7 @@ ListTable.prototype.render = function() {
|
|||
lines[yi + ry].dirty = true;
|
||||
} else {
|
||||
// middle
|
||||
++rx;
|
||||
rx++;
|
||||
}
|
||||
});
|
||||
ry += 1;
|
||||
|
@ -230,14 +226,16 @@ ListTable.prototype.render = function() {
|
|||
for (ry = 1; ry < height; ry++) {
|
||||
if (!lines[yi + ry]) break;
|
||||
rx = 0;
|
||||
self._maxes.slice(0, -1).forEach(function(max, i) {
|
||||
self._maxes.slice(0, -1).forEach(function(max) {
|
||||
rx += max;
|
||||
if (!lines[yi + ry][xi + rx + 1]) return;
|
||||
if (self.options.fillCellBorders !== false) {
|
||||
var lbg = lines[yi + ry][xi + rx][0] & 0x1ff;
|
||||
lines[yi + ry][xi + ++rx][0] = (battr & ~0x1ff) | lbg;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
|
||||
} else {
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
}
|
||||
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
|
||||
lines[yi + ry].dirty = true;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
var Text = require('./text');
|
||||
|
@ -19,8 +17,6 @@ var Text = require('./text');
|
|||
*/
|
||||
|
||||
function Loading(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Loading(options);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ var util = require('util');
|
|||
|
||||
var nextTick = global.setImmediate || process.nextTick.bind(process);
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var ScrollableText = require('./scrollabletext');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -18,8 +16,6 @@ var Box = require('./box');
|
|||
*/
|
||||
|
||||
function Message(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Message(options);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
var EventEmitter = require('../events').EventEmitter;
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
/**
|
||||
* Node
|
||||
*/
|
||||
|
|
|
@ -123,11 +123,10 @@ OverlayImage.prototype.type = 'overlayimage';
|
|||
OverlayImage.w3mdisplay = '/usr/lib/w3m/w3mimgdisplay';
|
||||
|
||||
OverlayImage.prototype.spawn = function(file, args, opt, callback) {
|
||||
var screen = this.screen
|
||||
, opt = opt || {}
|
||||
, spawn = require('child_process').spawn
|
||||
var spawn = require('child_process').spawn
|
||||
, ps;
|
||||
|
||||
opt = opt || {};
|
||||
ps = spawn(file, args, opt);
|
||||
|
||||
ps.on('error', function(err) {
|
||||
|
@ -154,7 +153,7 @@ OverlayImage.prototype.setImage = function(img, callback) {
|
|||
}
|
||||
this._settingImage = true;
|
||||
|
||||
var reset = function(err, success) {
|
||||
var reset = function() {
|
||||
self._settingImage = false;
|
||||
self._queue = self._queue || [];
|
||||
var item = self._queue.shift();
|
||||
|
@ -312,8 +311,6 @@ OverlayImage.prototype.renderImage = function(img, ratio, callback) {
|
|||
};
|
||||
|
||||
OverlayImage.prototype.clearImage = function(callback) {
|
||||
var self = this;
|
||||
|
||||
if (cp.execSync) {
|
||||
callback = callback || function(err, result) { return result; };
|
||||
try {
|
||||
|
@ -374,7 +371,6 @@ OverlayImage.prototype.clearImage = function(callback) {
|
|||
};
|
||||
|
||||
OverlayImage.prototype.imageSize = function(callback) {
|
||||
var self = this;
|
||||
var img = this.file;
|
||||
|
||||
if (cp.execSync) {
|
||||
|
@ -525,8 +521,6 @@ OverlayImage.prototype.getPixelRatio = function(callback) {
|
|||
};
|
||||
|
||||
OverlayImage.prototype.renderImageSync = function(img, ratio) {
|
||||
var self = this;
|
||||
|
||||
if (OverlayImage.hasW3MDisplay === false) {
|
||||
throw new Error('W3M Image Display not available.');
|
||||
}
|
||||
|
@ -695,8 +689,6 @@ OverlayImage.prototype.termSizeSync = function(_, recurse) {
|
|||
};
|
||||
|
||||
OverlayImage.prototype.getPixelRatioSync = function() {
|
||||
var self = this;
|
||||
|
||||
// XXX We could cache this, but sometimes it's better
|
||||
// to recalculate to be pixel perfect.
|
||||
if (this._ratio && !this._needsRatio) {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Input = require('./input');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
var Button = require('./button');
|
||||
|
@ -20,8 +18,6 @@ var Textbox = require('./textbox');
|
|||
*/
|
||||
|
||||
function Prompt(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Prompt(options);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
var Button = require('./button');
|
||||
|
@ -19,8 +17,6 @@ var Button = require('./button');
|
|||
*/
|
||||
|
||||
function Question(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Question(options);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Checkbox = require('./checkbox');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ var helpers = require('../helpers');
|
|||
|
||||
var Node = require('./node');
|
||||
var Log = require('./log');
|
||||
var Element = require('./element');
|
||||
var Box = require('./box');
|
||||
|
||||
/**
|
||||
|
@ -554,7 +555,7 @@ Screen.prototype._listenMouse = function(el) {
|
|||
// });
|
||||
|
||||
// Autofocus elements with the appropriate option.
|
||||
this.on('element click', function(el, data) {
|
||||
this.on('element click', function(el) {
|
||||
if (el.clickable === true && el.options.autoFocus !== false) {
|
||||
el.focus();
|
||||
}
|
||||
|
@ -667,7 +668,7 @@ Screen.prototype._initHover = function() {
|
|||
// XXX This can cause problems if the
|
||||
// terminal does not support allMotion.
|
||||
// Workaround: check to see if content is set.
|
||||
this.on('element mouseup', function(el, data) {
|
||||
this.on('element mouseup', function(el) {
|
||||
if (!self._hoverText.getContent()) return;
|
||||
if (!el._hoverOptions) return;
|
||||
self.append(self._hoverText);
|
||||
|
@ -1739,11 +1740,12 @@ Screen.prototype.spawn = function(file, args, options) {
|
|||
|
||||
var screen = this
|
||||
, program = screen.program
|
||||
, options = options || {}
|
||||
, spawn = require('child_process').spawn
|
||||
, mouse = program.mouseEnabled
|
||||
, ps;
|
||||
|
||||
options = options || {};
|
||||
|
||||
options.stdio = options.stdio || 'inherit';
|
||||
|
||||
program.lsaveCursor('spawn');
|
||||
|
@ -1773,8 +1775,8 @@ Screen.prototype.spawn = function(file, args, options) {
|
|||
// program.csr(0, program.rows - 1);
|
||||
if (mouse) {
|
||||
program.enableMouse();
|
||||
if (self.options.sendFocus) {
|
||||
self.program.setMouse({ sendFocus: true }, true);
|
||||
if (screen.options.sendFocus) {
|
||||
screen.program.setMouse({ sendFocus: true }, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1794,8 +1796,7 @@ Screen.prototype.spawn = function(file, args, options) {
|
|||
};
|
||||
|
||||
Screen.prototype.exec = function(file, args, options, callback) {
|
||||
var callback = arguments[arguments.length - 1]
|
||||
, ps = this.spawn(file, args, options);
|
||||
var ps = this.spawn(file, args, options);
|
||||
|
||||
ps.on('error', function(err) {
|
||||
if (!callback) return;
|
||||
|
@ -1827,7 +1828,6 @@ Screen.prototype.readEditor = function(options, callback) {
|
|||
options = options || {};
|
||||
|
||||
var self = this
|
||||
, fs = require('fs')
|
||||
, editor = options.editor || process.env.EDITOR || 'vi'
|
||||
, name = options.name || process.title || 'blessed'
|
||||
, rnd = Math.random().toString(36).split('.').pop()
|
||||
|
@ -1862,14 +1862,12 @@ Screen.prototype.readEditor = function(options, callback) {
|
|||
};
|
||||
|
||||
Screen.prototype.displayImage = function(file, callback) {
|
||||
var self = this;
|
||||
|
||||
if (!file) {
|
||||
if (!callback) return;
|
||||
return callback(new Error('No image.'));
|
||||
}
|
||||
|
||||
var file = path.resolve(process.cwd(), file);
|
||||
file = path.resolve(process.cwd(), file);
|
||||
|
||||
if (!~file.indexOf('://')) {
|
||||
file = 'file://' + file;
|
||||
|
@ -2258,9 +2256,9 @@ var dangles = {
|
|||
'\u2502': true // '│'
|
||||
};
|
||||
|
||||
var cdangles = {
|
||||
'\u250c': true // '┌'
|
||||
};
|
||||
// var cdangles = {
|
||||
// '\u250c': true // '┌'
|
||||
// };
|
||||
|
||||
// Every ACS angle character can be
|
||||
// represented by 4 bits ordered like this:
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -97,7 +95,7 @@ function ScrollableBox(options) {
|
|||
// If mouseup occurs out of the window, no mouseup event fires, and
|
||||
// scrollbar will drag again on mousedown until another mouseup
|
||||
// occurs.
|
||||
self.onScreenEvent('mouseup', smu = function(data) {
|
||||
self.onScreenEvent('mouseup', smu = function() {
|
||||
self._scrollingBar = false;
|
||||
self.removeScreenEvent('mousedown', smd);
|
||||
self.removeScreenEvent('mouseup', smu);
|
||||
|
@ -108,11 +106,11 @@ function ScrollableBox(options) {
|
|||
}
|
||||
|
||||
if (options.mouse) {
|
||||
this.on('wheeldown', function(el, data) {
|
||||
this.on('wheeldown', function() {
|
||||
self.scroll(self.height / 2 | 0 || 1);
|
||||
self.screen.render();
|
||||
});
|
||||
this.on('wheelup', function(el, data) {
|
||||
this.on('wheelup', function() {
|
||||
self.scroll(-(self.height / 2 | 0) || -1);
|
||||
self.screen.render();
|
||||
});
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var ScrollableBox = require('./scrollablebox');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -112,7 +110,6 @@ Table.prototype.setRows =
|
|||
Table.prototype.setData = function(rows) {
|
||||
var self = this
|
||||
, text = ''
|
||||
, line = ''
|
||||
, align = this.align;
|
||||
|
||||
this.rows = rows || [];
|
||||
|
@ -122,7 +119,6 @@ Table.prototype.setData = function(rows) {
|
|||
if (!this._maxes) return;
|
||||
|
||||
this.rows.forEach(function(row, i) {
|
||||
var isHeader = i === 0;
|
||||
var isFooter = i === self.rows.length - 1;
|
||||
row.forEach(function(cell, i) {
|
||||
var width = self._maxes[i];
|
||||
|
@ -182,9 +178,7 @@ Table.prototype.render = function() {
|
|||
|
||||
var lines = this.screen.lines
|
||||
, xi = coords.xi
|
||||
, xl = coords.xl
|
||||
, yi = coords.yi
|
||||
, yl = coords.yl
|
||||
, rx
|
||||
, ry
|
||||
, i;
|
||||
|
@ -248,15 +242,18 @@ Table.prototype.render = function() {
|
|||
// right side
|
||||
if (ry === 0) {
|
||||
// top
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
// lines[yi + ry][xi + rx][1] = '\u2510'; // '┐'
|
||||
} else if (ry / 2 === self.rows.length) {
|
||||
// bottom
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
// lines[yi + ry][xi + rx][1] = '\u2518'; // '┘'
|
||||
} else {
|
||||
// middle
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
lines[yi + ry][xi + rx][1] = '\u2524'; // '┤'
|
||||
// XXX If we alter iwidth and iright for no borders - nothing should be written here
|
||||
if (!self.border.right) {
|
||||
|
@ -270,7 +267,8 @@ Table.prototype.render = function() {
|
|||
// center
|
||||
if (ry === 0) {
|
||||
// top
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
lines[yi + ry][xi + rx][1] = '\u252c'; // '┬'
|
||||
// XXX If we alter iheight and itop for no borders - nothing should be written here
|
||||
if (!self.border.top) {
|
||||
|
@ -278,7 +276,8 @@ Table.prototype.render = function() {
|
|||
}
|
||||
} else if (ry / 2 === self.rows.length) {
|
||||
// bottom
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
lines[yi + ry][xi + rx][1] = '\u2534'; // '┴'
|
||||
// XXX If we alter iheight and ibottom for no borders - nothing should be written here
|
||||
if (!self.border.bottom) {
|
||||
|
@ -288,12 +287,14 @@ Table.prototype.render = function() {
|
|||
// middle
|
||||
if (self.options.fillCellBorders) {
|
||||
var lbg = (ry <= 2 ? hattr : cattr) & 0x1ff;
|
||||
lines[yi + ry][xi + ++rx][0] = (battr & ~0x1ff) | lbg;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
|
||||
} else {
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
}
|
||||
lines[yi + ry][xi + rx][1] = '\u253c'; // '┼'
|
||||
// ++rx;
|
||||
// rx++;
|
||||
}
|
||||
lines[yi + ry].dirty = true;
|
||||
});
|
||||
|
@ -304,15 +305,17 @@ Table.prototype.render = function() {
|
|||
for (ry = 1; ry < self.rows.length * 2; ry++) {
|
||||
if (!lines[yi + ry]) break;
|
||||
rx = 0;
|
||||
self._maxes.slice(0, -1).forEach(function(max, i) {
|
||||
self._maxes.slice(0, -1).forEach(function(max) {
|
||||
rx += max;
|
||||
if (!lines[yi + ry][xi + rx + 1]) return;
|
||||
if (ry % 2 !== 0) {
|
||||
if (self.options.fillCellBorders) {
|
||||
var lbg = (ry <= 2 ? hattr : cattr) & 0x1ff;
|
||||
lines[yi + ry][xi + ++rx][0] = (battr & ~0x1ff) | lbg;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = (battr & ~0x1ff) | lbg;
|
||||
} else {
|
||||
lines[yi + ry][xi + ++rx][0] = battr;
|
||||
rx++;
|
||||
lines[yi + ry][xi + rx][0] = battr;
|
||||
}
|
||||
lines[yi + ry][xi + rx][1] = '\u2502'; // '│'
|
||||
lines[yi + ry].dirty = true;
|
||||
|
@ -321,7 +324,7 @@ Table.prototype.render = function() {
|
|||
}
|
||||
});
|
||||
rx = 1;
|
||||
self._maxes.forEach(function(max, i) {
|
||||
self._maxes.forEach(function(max) {
|
||||
while (max--) {
|
||||
if (ry % 2 === 0) {
|
||||
if (!lines[yi + ry]) break;
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
var nextTick = global.setImmediate || process.nextTick.bind(process);
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
|
||||
|
@ -20,8 +18,6 @@ var Box = require('./box');
|
|||
*/
|
||||
|
||||
function Terminal(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Terminal(options);
|
||||
}
|
||||
|
@ -77,7 +73,7 @@ Terminal.prototype.bootstrap = function() {
|
|||
get ownerDocument() { return element; },
|
||||
addEventListener: function() {},
|
||||
removeEventListener: function() {},
|
||||
getElementsByTagName: function(name) { return [element]; },
|
||||
getElementsByTagName: function() { return [element]; },
|
||||
getElementById: function() { return element; },
|
||||
parentNode: null,
|
||||
offsetParent: null,
|
||||
|
@ -348,7 +344,7 @@ Terminal.prototype._isMouse = function(buf) {
|
|||
};
|
||||
|
||||
Terminal.prototype.setScroll =
|
||||
Terminal.prototype.scrollTo = function(offset, always) {
|
||||
Terminal.prototype.scrollTo = function(offset) {
|
||||
this.term.ydisp = offset;
|
||||
return this.emit('scroll');
|
||||
};
|
||||
|
@ -357,7 +353,7 @@ Terminal.prototype.getScroll = function() {
|
|||
return this.term.ydisp;
|
||||
};
|
||||
|
||||
Terminal.prototype.scroll = function(offset, always) {
|
||||
Terminal.prototype.scroll = function(offset) {
|
||||
this.term.scrollDisp(offset);
|
||||
return this.emit('scroll');
|
||||
};
|
||||
|
@ -372,7 +368,7 @@ Terminal.prototype.getScrollHeight = function() {
|
|||
return this.term.rows - 1;
|
||||
};
|
||||
|
||||
Terminal.prototype.getScrollPerc = function(s) {
|
||||
Terminal.prototype.getScrollPerc = function() {
|
||||
return (this.term.ydisp / this.term.ybase) * 100;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Element = require('./element');
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ var unicode = require('../unicode');
|
|||
|
||||
var nextTick = global.setImmediate || process.nextTick.bind(process);
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Input = require('./input');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* Modules
|
||||
*/
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Textarea = require('./textarea');
|
||||
|
||||
|
@ -18,8 +16,6 @@ var Textarea = require('./textarea');
|
|||
*/
|
||||
|
||||
function Textbox(options) {
|
||||
var self = this;
|
||||
|
||||
if (!(this instanceof Node)) {
|
||||
return new Textbox(options);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
|
||||
var cp = require('child_process');
|
||||
|
||||
var nextTick = global.setImmediate || process.nextTick.bind(process);
|
||||
|
||||
var helpers = require('../helpers');
|
||||
|
||||
var Node = require('./node');
|
||||
var Box = require('./box');
|
||||
var Terminal = require('./terminal');
|
||||
|
|
Loading…
Reference in New Issue