mirror of
https://github.com/nuintun/command-manager.git
synced 2025-08-17 19:39:34 +08:00
update files
This commit is contained in:
parent
8ec477996c
commit
7e450e555c
@ -11,5 +11,6 @@ module.exports = {
|
|||||||
osc: 3,
|
osc: 3,
|
||||||
charset: 4,
|
charset: 4,
|
||||||
dcs: 5,
|
dcs: 5,
|
||||||
ignore: 6
|
ignore: 6,
|
||||||
|
udk: { type: 'udk' }
|
||||||
};
|
};
|
||||||
|
@ -48,7 +48,8 @@ module.exports = function (Terminal){
|
|||||||
|
|
||||||
var l = data.length;
|
var l = data.length;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var cs, ch;
|
var ch = null;
|
||||||
|
var cs, lch;
|
||||||
|
|
||||||
this.refreshStart = this.y;
|
this.refreshStart = this.y;
|
||||||
this.refreshEnd = this.y;
|
this.refreshEnd = this.y;
|
||||||
@ -58,7 +59,7 @@ module.exports = function (Terminal){
|
|||||||
this.maxRange();
|
this.maxRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < l; i++) {
|
for (lch = ch; i < l; i++) {
|
||||||
ch = data[i];
|
ch = data[i];
|
||||||
|
|
||||||
switch (this.state) {
|
switch (this.state) {
|
||||||
@ -165,7 +166,7 @@ module.exports = function (Terminal){
|
|||||||
case 'P':
|
case 'P':
|
||||||
this.params = [];
|
this.params = [];
|
||||||
this.prefix = '';
|
this.prefix = '';
|
||||||
this.currentParam = 0;
|
this.currentParam = '';
|
||||||
this.state = states.dcs;
|
this.state = states.dcs;
|
||||||
break;
|
break;
|
||||||
// ESC _ Application Program Command ( APC is 0x9f).
|
// ESC _ Application Program Command ( APC is 0x9f).
|
||||||
@ -400,8 +401,14 @@ module.exports = function (Terminal){
|
|||||||
// OSC Ps ; Pt ST
|
// OSC Ps ; Pt ST
|
||||||
// OSC Ps ; Pt BEL
|
// OSC Ps ; Pt BEL
|
||||||
// Set Text Parameters.
|
// Set Text Parameters.
|
||||||
if (ch === '\x1b' || ch === '\x07') {
|
if ((lch === '\x1b' && ch === '\\') || ch === '\x07') {
|
||||||
if (ch === '\x1b') i++;
|
if (lch === '\x1b') {
|
||||||
|
if (typeof this.currentParam === 'string') {
|
||||||
|
this.currentParam = this.currentParam.slice(0, -1);
|
||||||
|
} else if (typeof this.currentParam == 'number') {
|
||||||
|
this.currentParam = (this.currentParam - ('\x1b'.charCodeAt(0) - 48)) / 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.params.push(this.currentParam);
|
this.params.push(this.currentParam);
|
||||||
|
|
||||||
@ -706,39 +713,58 @@ module.exports = function (Terminal){
|
|||||||
this.postfix = '';
|
this.postfix = '';
|
||||||
break;
|
break;
|
||||||
case states.dcs:
|
case states.dcs:
|
||||||
if (ch === '\x1b' || ch === '\x07') {
|
if ((lch === '\x1b' && ch === '\\') || ch === '\x07') {
|
||||||
if (ch === '\x1b') i++;
|
// Workarounds:
|
||||||
|
if (this.prefix === 'tmux;\x1b') {
|
||||||
|
// Tmux only accepts ST, not BEL:
|
||||||
|
if (ch === '\x07') {
|
||||||
|
this.currentParam += ch;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lch === '\x1b') {
|
||||||
|
if (typeof this.currentParam === 'string') {
|
||||||
|
this.currentParam = this.currentParam.slice(0, -1);
|
||||||
|
} else if (typeof this.currentParam == 'number') {
|
||||||
|
this.currentParam = (this.currentParam - ('\x1b'.charCodeAt(0) - 48)) / 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.params.push(this.currentParam);
|
||||||
|
|
||||||
|
var pt = this.params[this.params.length - 1];
|
||||||
|
|
||||||
switch (this.prefix) {
|
switch (this.prefix) {
|
||||||
// User-Defined Keys (DECUDK).
|
// User-Defined Keys (DECUDK).
|
||||||
case '':
|
case states.udk:
|
||||||
break;
|
break;
|
||||||
// Request Status String (DECRQSS).
|
// Request Status String (DECRQSS).
|
||||||
// test: echo -e '\eP$q"p\e\\'
|
// test: echo -e '\eP$q"p\e\\'
|
||||||
case '$q':
|
case '$q':
|
||||||
var valid = 0;
|
var valid = 0;
|
||||||
var pt = this.currentParam;
|
|
||||||
|
|
||||||
switch (pt) {
|
switch (pt) {
|
||||||
// DECSCA
|
// DECSCA
|
||||||
case '"q':
|
case '"q':
|
||||||
pt = '0"q';
|
|
||||||
valid = 1;
|
valid = 1;
|
||||||
|
pt = '0"q';
|
||||||
break;
|
break;
|
||||||
// DECSCL
|
// DECSCL
|
||||||
case '"p':
|
case '"p':
|
||||||
pt = '61"p';
|
|
||||||
valid = 1;
|
valid = 1;
|
||||||
|
pt = '61"p';
|
||||||
break;
|
break;
|
||||||
// DECSTBM
|
// DECSTBM
|
||||||
case 'r':
|
case 'r':
|
||||||
pt = '' + (this.scrollTop + 1) + ';' + (this.scrollBottom + 1) + 'r';
|
|
||||||
valid = 1;
|
valid = 1;
|
||||||
|
pt = '' + (this.scrollTop + 1) + ';' + (this.scrollBottom + 1) + 'r';
|
||||||
break;
|
break;
|
||||||
// SGR
|
// SGR
|
||||||
case 'm':
|
case 'm':
|
||||||
pt = '0m';
|
// TODO: Parse this.curAttr here.
|
||||||
valid = 1;
|
// Not implemented.
|
||||||
|
valid = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.error('Unknown DCS Pt: %s.', pt);
|
this.error('Unknown DCS Pt: %s.', pt);
|
||||||
@ -759,7 +785,7 @@ module.exports = function (Terminal){
|
|||||||
// DCS + q Pt ST
|
// DCS + q Pt ST
|
||||||
// test: echo -ne '\eP+q6b64\e\\'
|
// test: echo -ne '\eP+q6b64\e\\'
|
||||||
case '+q':
|
case '+q':
|
||||||
valid = 0;
|
valid = false;
|
||||||
|
|
||||||
this.send('\x1bP' + valid + '+r' + pt + '\x1b\\');
|
this.send('\x1bP' + valid + '+r' + pt + '\x1b\\');
|
||||||
break;
|
break;
|
||||||
@ -776,27 +802,29 @@ module.exports = function (Terminal){
|
|||||||
this.currentParam = 0;
|
this.currentParam = 0;
|
||||||
this.prefix = '';
|
this.prefix = '';
|
||||||
this.state = states.normal;
|
this.state = states.normal;
|
||||||
} else if (!this.currentParam) {
|
|
||||||
if (!this.prefix && ch !== '$' && ch !== '+') {
|
|
||||||
this.currentParam = ch;
|
|
||||||
} else if (this.prefix.length === 2) {
|
|
||||||
this.currentParam = ch;
|
|
||||||
} else {
|
|
||||||
this.prefix += ch;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.currentParam += ch;
|
this.currentParam += ch;
|
||||||
|
|
||||||
|
if (!this.prefix) {
|
||||||
|
if (/^\d*;\d*\|/.test(this.currentParam)) {
|
||||||
|
this.prefix = states.udk;
|
||||||
|
this.params = this.currentParam.split(/[;|]/).map(function (n){
|
||||||
|
if (!n.length) return 0;
|
||||||
|
return +n;
|
||||||
|
}).slice(0, -1);
|
||||||
|
this.currentParam = '';
|
||||||
|
} else if (/^[$+][a-zA-Z]/.test(this.currentParam)
|
||||||
|
|| /^\w+;\x1b/.test(this.currentParam)) {
|
||||||
|
this.prefix = this.currentParam;
|
||||||
|
this.currentParam = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case states.ignore:
|
case states.ignore:
|
||||||
// For PM and APC.
|
// For PM and APC.
|
||||||
if (ch === '\x1b' || ch === '\x07') {
|
if ((lch === '\x1b' && ch === '\\') || ch === '\x07') {
|
||||||
if (ch === '\x1b') i++;
|
|
||||||
this.stateData = '';
|
|
||||||
this.state = states.normal;
|
this.state = states.normal;
|
||||||
} else {
|
|
||||||
if (!this.stateData) this.stateData = '';
|
|
||||||
this.stateData += ch;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user