more ext work
This commit is contained in:
parent
eefc2842a6
commit
8d92eb49c6
150
lib/tput.js
150
lib/tput.js
|
@ -213,17 +213,21 @@ Tput.prototype.parseTerminfo = function(data) {
|
|||
// For xterm, offsets:
|
||||
// { header: '0 - 10',
|
||||
// bools: '10 - 12',
|
||||
// numbers: '12 - 16',
|
||||
// strings: '16 - 130',
|
||||
// stringData: '130 - 612',
|
||||
// numbers: '12 - 14',
|
||||
// strings: '14 - 128', // length: 114 (57 short)
|
||||
// symstrings: '128 - 248', // length: 120 (60 short)
|
||||
// stringData: '248 - 612',
|
||||
// sym: '612 - 928' }
|
||||
//
|
||||
// Real header size: 10
|
||||
// Real bools size: 2
|
||||
// Real numbers size: 4
|
||||
// Real string-offset size: 114
|
||||
// Real table size: 482
|
||||
// Real sym-offset size: 120
|
||||
// Real table size: 364
|
||||
// Real sym size: 316
|
||||
// 364 + 316 === 680 (lastStrTableOffset)
|
||||
// data.length - h.lastStrTableOffset === 248 (sym-offset size)
|
||||
|
||||
Tput.prototype.parseExtended = function(data, _data, _h, _i) {
|
||||
var info = {}
|
||||
|
@ -276,13 +280,6 @@ Tput.prototype.parseExtended = function(data, _data, _h, _i) {
|
|||
}
|
||||
}
|
||||
|
||||
// 0000920: 1b6c 001b 6d00 0200 0100 3900 7500 a802 .l..m.....9.u...
|
||||
// 0000930: 0100 ffff ffff 0000 0700 0e00 1500 1c00 ................
|
||||
// XXX - WHY?
|
||||
if (data[i + 1] === 0377 && data[i] === 0377) {
|
||||
i += 2;
|
||||
}
|
||||
|
||||
// Strings Section
|
||||
var _strings = [];
|
||||
l = i + h.strCount * 2;
|
||||
|
@ -294,9 +291,58 @@ Tput.prototype.parseExtended = function(data, _data, _h, _i) {
|
|||
}
|
||||
}
|
||||
|
||||
// 0000990: 3b01 4201 4901 5001 5701 5e01 6501 ffff ;.B.I.P.W.^.e...
|
||||
// 00009a0: ffff ffff ffff 0000 0300 0600 0900 0c00 ................
|
||||
// i = l;
|
||||
// string offsets: 14 - 128, length: 114 (57 short)
|
||||
// sym offsets: 128 - 248, length: 120 (60 short)
|
||||
var stroff = [];
|
||||
var symoff = [];
|
||||
var stroffsets = data.slice(14, 128);
|
||||
var symoffsets = data.slice(128, 248);
|
||||
for (var a = 0; a < stroffsets.length; a += 2) {
|
||||
stroff.push((stroffsets[a + 1] << 8) | stroffsets[a]);
|
||||
}
|
||||
for (var a = 0; a < symoffsets.length; a += 2) {
|
||||
symoff.push((symoffsets[a + 1] << 8) | symoffsets[a]);
|
||||
}
|
||||
console.log(stroff);
|
||||
console.log(symoff);
|
||||
var end = data.slice(248, 260);
|
||||
console.log(JSON.stringify(end.toString('ascii')));
|
||||
//process.exit(0);
|
||||
|
||||
// need to get from 128 to 248
|
||||
// diff: 120
|
||||
//i += 60 * 2;
|
||||
i = data.length - h.lastStrTableOffset;
|
||||
|
||||
/*
|
||||
var t = [];
|
||||
data = data.slice(16, 248);
|
||||
for (var a = 0; a < data.length; a += 2) {
|
||||
t.push((data[a + 1] << 8) | data[a]);
|
||||
}
|
||||
console.log(t.slice(0, h.strCount));
|
||||
console.log(t.slice(h.strCount));
|
||||
process.exit(0);
|
||||
|
||||
data = data.slice(248, 612).toString('ascii').split('\0');
|
||||
console.log(data);
|
||||
process.exit(0);
|
||||
*/
|
||||
|
||||
|
||||
//while (!(i % 2) && data[i] !== 0x1b) i++;
|
||||
|
||||
//l = i + h.strCount * 2 + 6;
|
||||
//for (; i < l; i += 2);
|
||||
|
||||
//l = i + h.strCount * 2;
|
||||
//for (; i < l; i += 2);
|
||||
//while (data[i] !== 0x1b) i++;
|
||||
|
||||
//console.log(_strings);
|
||||
//console.log(_strings.length);
|
||||
//console.log(data.slice(i - 10, i + 10));
|
||||
//process.exit(0);
|
||||
|
||||
// String Table
|
||||
_strings.forEach(function(offset, k) {
|
||||
|
@ -308,9 +354,6 @@ Tput.prototype.parseExtended = function(data, _data, _h, _i) {
|
|||
var s = i + offset
|
||||
, j = s;
|
||||
|
||||
// XXX - WHY?
|
||||
while (data[s - 1] !== 0) s--;
|
||||
|
||||
while (data[j]) j++;
|
||||
|
||||
if (s >= data.length || j > data.length) {
|
||||
|
@ -351,85 +394,12 @@ Tput.prototype.parseExtended = function(data, _data, _h, _i) {
|
|||
info.strings[sym.shift()] = string;
|
||||
});
|
||||
|
||||
assert.deepEqual(info, ext_test);
|
||||
|
||||
console.log(info);
|
||||
process.exit(0);
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
var ext_test =
|
||||
{ header:
|
||||
{ dataSize: 928,
|
||||
headerSize: 10,
|
||||
boolCount: 2,
|
||||
numCount: 1,
|
||||
strCount: 57,
|
||||
strTableSize: 117,
|
||||
lastStrTableOffset: 680,
|
||||
total: 245 },
|
||||
bools: { AX: true, XT: false },
|
||||
numbers: { U8: -1 },
|
||||
strings:
|
||||
{ XM: '\u0003',
|
||||
kDC3: '\f',
|
||||
kDC4: ' ',
|
||||
kDC5: '.',
|
||||
kDC6: 'B',
|
||||
kDC7: 'T',
|
||||
kDN: 'l',
|
||||
kDN3: '~',
|
||||
kDN4: '<27>',
|
||||
kDN5: '<27>',
|
||||
kDN6: '<27>',
|
||||
kDN7: '<27>',
|
||||
kEND3: '<27>',
|
||||
kEND4: '<27>',
|
||||
kEND5: '\u0003\u0001\t\u0001\u000f\u0001\u0013\u0001\u0018\u0001\u001d\u0001"\u0001\'\u0001,\u00010\u00014\u00018\u0001\u001b[3;3~',
|
||||
kEND6: '\u0003\u0001\t\u0001\u000f\u0001\u0013\u0001\u0018\u0001\u001d\u0001"\u0001\'\u0001,\u00010\u00014\u00018\u0001\u001b[3;3~',
|
||||
kEND7: '\u0003\u0001\t\u0001\u000f\u0001\u0013\u0001\u0018\u0001\u001d\u0001"\u0001\'\u0001,\u00010\u00014\u00018\u0001\u001b[3;3~',
|
||||
kHOM3: '\u0003\u0001\t\u0001\u000f\u0001\u0013\u0001\u0018\u0001\u001d\u0001"\u0001\'\u0001,\u00010\u00014\u00018\u0001\u001b[3;3~',
|
||||
kHOM4: '\u001b[3;4~',
|
||||
kHOM5: '\u001b[3;5~',
|
||||
kHOM6: '\u001b[3;6~',
|
||||
kHOM7: '\u001b[3;7~',
|
||||
kIC3: '\u001b[1;2B',
|
||||
kIC4: '\u001b[1;3B',
|
||||
kIC5: '\u001b[1;4B',
|
||||
kIC6: '\u001b[1;5B',
|
||||
kIC7: '\u001b[1;6B',
|
||||
kLFT3: '\u001b[1;7B',
|
||||
kLFT4: '\u001b[1;3F',
|
||||
kLFT5: '\u001b[1;4F',
|
||||
kLFT6: '\u001b[1;5F',
|
||||
kLFT7: '\u001b[1;6F',
|
||||
kNXT3: '\u001b[1;7F',
|
||||
kNXT4: '\u001b[1;3H',
|
||||
kNXT5: '\u001b[1;4H',
|
||||
kNXT6: '\u001b[1;5H',
|
||||
kNXT7: '\u001b[1;6H',
|
||||
kPRV3: '\u001b[1;7H',
|
||||
kPRV4: '\u001b[2;3~',
|
||||
kPRV5: '\u001b[2;4~',
|
||||
kPRV6: '\u001b[2;5~',
|
||||
kPRV7: '\u001b[2;6~',
|
||||
kRIT3: '\u001b[2;7~',
|
||||
kRIT4: '\u001b[1;3D',
|
||||
kRIT5: '\u001b[1;4D',
|
||||
kRIT6: '\u001b[1;5D',
|
||||
kRIT7: '\u001b[1;6D',
|
||||
kUP: '\u001b[1;7D',
|
||||
kUP3: '\u001b[6;3~',
|
||||
kUP4: '\u001b[6;4~',
|
||||
kUP5: '\u001b[6;5~',
|
||||
kUP6: '\u001b[6;6~',
|
||||
kUP7: '',
|
||||
ka2: '',
|
||||
kb1: '',
|
||||
kb3: '',
|
||||
kc2: '\u0003' } };
|
||||
|
||||
/**
|
||||
* Compiler - terminfo cap->javascript
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue