mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-03 14:45:33 +00:00
clean up comments
This commit is contained in:
parent
3e8cea6a23
commit
f5fdf2a9c0
6
example/tput.js
Normal file
6
example/tput.js
Normal file
@ -0,0 +1,6 @@
|
||||
var Tput = require('../lib/tput');
|
||||
|
||||
var tput = new Tput(process.argv[2] || 'xterm');
|
||||
tput.colors();
|
||||
|
||||
console.log(tput.info);
|
53
lib/tput.js
53
lib/tput.js
@ -22,6 +22,10 @@ var assert = require('assert')
|
||||
*/
|
||||
|
||||
function Tput(term) {
|
||||
if (!(this instanceof Tput)) {
|
||||
return new Tput(term);
|
||||
}
|
||||
|
||||
this.term = term;
|
||||
this.data = null;
|
||||
this.info = {};
|
||||
@ -66,9 +70,6 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
|
||||
i = h.headerSize;
|
||||
|
||||
// short int = 2 8bit bytes, first byte - least significant, second byte - most significant
|
||||
// little endian
|
||||
|
||||
// Names Section
|
||||
var names = data.toString('ascii', i, i + h.namesSize - 1)
|
||||
, parts = names.split('|')
|
||||
@ -84,14 +85,6 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
assert.equal(data[i], 0);
|
||||
i++;
|
||||
|
||||
// Might need to add another one here, without the extra bool defs there is 1 undefined.
|
||||
// Example doesn't show this.
|
||||
//i++;
|
||||
//if (i % 2) {
|
||||
// assert.equal(data[i], 0);
|
||||
// i++;
|
||||
//}
|
||||
|
||||
// Booleans Section
|
||||
// One byte for each flag
|
||||
// Same order as <term.h>
|
||||
@ -104,7 +97,6 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
}
|
||||
|
||||
// Null byte in between to make sure numbers begin on an even byte.
|
||||
// Maybe subtract one from boolCount above and always do this instead.
|
||||
if (i % 2) {
|
||||
assert.equal(data[i], 0);
|
||||
i++;
|
||||
@ -123,14 +115,6 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
}
|
||||
}
|
||||
|
||||
// Null byte in between to make sure numbers begin on an even byte.
|
||||
// Does it explicitly say to do this? tput does not seem to do this,
|
||||
// but it seems to work on xterm (?).
|
||||
//if (i % 2) {
|
||||
// assert.equal(data[i], 0);
|
||||
// i++;
|
||||
//}
|
||||
|
||||
// Strings Section
|
||||
info.strings = {};
|
||||
l = i + h.strCount * 2;
|
||||
@ -145,12 +129,9 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
}
|
||||
|
||||
// String Table
|
||||
// %p, %i, etc - parameters
|
||||
// $<num> - padding
|
||||
Object.keys(info.strings).forEach(function(key) {
|
||||
if (info.strings[key] === -1) {
|
||||
delete info.strings[key];
|
||||
//info.strings[key] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -161,17 +142,16 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
|
||||
if (s >= data.length || j > data.length) {
|
||||
delete info.strings[key];
|
||||
//info.strings[key] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
info.strings[key] = data.toString('ascii', s, j);
|
||||
});
|
||||
|
||||
// Extended Header, +1 or -1, not sure.
|
||||
i += h.strTableSize + 1;
|
||||
// Extended Header
|
||||
if (this.extended) {
|
||||
i += h.strTableSize + 1; // offset?
|
||||
l = data.length;
|
||||
if (0)
|
||||
if (i < l) {
|
||||
info.extended = this.parseExtended(data.slice(i));
|
||||
Object.keys(info.extended).forEach(function(key) {
|
||||
@ -179,8 +159,7 @@ Tput.prototype.parseTermInfo = function(data) {
|
||||
});
|
||||
delete info.extended;
|
||||
}
|
||||
|
||||
console.log(info);
|
||||
}
|
||||
|
||||
return info;
|
||||
};
|
||||
@ -220,7 +199,6 @@ Tput.prototype.parseExtended = function(data) {
|
||||
}
|
||||
|
||||
// Null byte in between to make sure numbers begin on an even byte.
|
||||
// Maybe subtract one from boolCount above and always do this instead.
|
||||
if (i % 2) {
|
||||
assert.equal(data[i], 0);
|
||||
i++;
|
||||
@ -239,14 +217,6 @@ Tput.prototype.parseExtended = function(data) {
|
||||
}
|
||||
}
|
||||
|
||||
// Null byte in between to make sure numbers begin on an even byte.
|
||||
// Does it explicitly say to do this? tput does not seem to do this,
|
||||
// but it seems to work on xterm (?).
|
||||
//if (i % 2) {
|
||||
// assert.equal(data[i], 0);
|
||||
// i++;
|
||||
//}
|
||||
|
||||
// Strings Section
|
||||
info.strings = {};
|
||||
l = i + h.strCount * 2;
|
||||
@ -261,12 +231,9 @@ Tput.prototype.parseExtended = function(data) {
|
||||
}
|
||||
|
||||
// String Table
|
||||
// %p, %i, etc - parameters
|
||||
// $<num> - padding
|
||||
Object.keys(info.strings).forEach(function(key) {
|
||||
if (info.strings[key] === -1) {
|
||||
delete info.strings[key];
|
||||
//info.strings[key] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -277,7 +244,6 @@ Tput.prototype.parseExtended = function(data) {
|
||||
|
||||
if (s >= data.length || j > data.length) {
|
||||
delete info.strings[key];
|
||||
//info.strings[key] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1088,5 +1054,4 @@ Object.keys(Tput.prototype).forEach(function(key) {
|
||||
};
|
||||
});
|
||||
|
||||
var tput = new Tput(process.argv[2] || 'xterm');
|
||||
tput.colors();
|
||||
module.exports = Tput;
|
||||
|
Loading…
x
Reference in New Issue
Block a user