@xterm/xterm 6.1.0-beta.200 → 6.1.0-beta.202
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +7 -7
- package/lib/xterm.mjs.map +2 -2
- package/package.json +2 -2
- package/src/common/Version.ts +1 -1
- package/src/common/parser/EscapeSequenceParser.ts +20 -22
- package/src/common/parser/Params.ts +13 -0
- package/src/common/parser/Types.ts +2 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/xterm",
|
|
3
3
|
"description": "Full xterm terminal, in your browser",
|
|
4
|
-
"version": "6.1.0-beta.
|
|
4
|
+
"version": "6.1.0-beta.202",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"ws": "^8.2.3",
|
|
120
120
|
"xterm-benchmark": "^0.3.1"
|
|
121
121
|
},
|
|
122
|
-
"commit": "
|
|
122
|
+
"commit": "cbe59a17ae307b311557a312ebaa44f23077b8d6"
|
|
123
123
|
}
|
package/src/common/Version.ts
CHANGED
|
@@ -247,6 +247,8 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
247
247
|
// handler lookup containers
|
|
248
248
|
protected _printHandler: PrintHandlerType;
|
|
249
249
|
protected _executeHandlers: { [flag: number]: ExecuteHandlerType };
|
|
250
|
+
// fast path for EXE bytes < 0x18
|
|
251
|
+
protected _executeHandlersArr: (ExecuteHandlerType | undefined)[];
|
|
250
252
|
protected _csiHandlers: IHandlerCollection<CsiHandlerType>;
|
|
251
253
|
protected _escHandlers: IHandlerCollection<EscHandlerType>;
|
|
252
254
|
protected readonly _oscParser: IOscParser;
|
|
@@ -290,11 +292,13 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
290
292
|
this._errorHandlerFb = (state: IParsingState): IParsingState => state;
|
|
291
293
|
this._printHandler = this._printHandlerFb;
|
|
292
294
|
this._executeHandlers = Object.create(null);
|
|
295
|
+
this._executeHandlersArr = new Array(0x18).fill(undefined);
|
|
293
296
|
this._csiHandlers = Object.create(null);
|
|
294
297
|
this._escHandlers = Object.create(null);
|
|
295
298
|
this._register(toDisposable(() => {
|
|
296
299
|
this._csiHandlers = Object.create(null);
|
|
297
300
|
this._executeHandlers = Object.create(null);
|
|
301
|
+
this._executeHandlersArr = new Array(0x18).fill(undefined);
|
|
298
302
|
this._escHandlers = Object.create(null);
|
|
299
303
|
}));
|
|
300
304
|
this._oscParser = this._register(new OscParser());
|
|
@@ -381,10 +385,14 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
381
385
|
}
|
|
382
386
|
|
|
383
387
|
public setExecuteHandler(flag: string, handler: ExecuteHandlerType): void {
|
|
384
|
-
|
|
388
|
+
const code = flag.charCodeAt(0);
|
|
389
|
+
this._executeHandlers[code] = handler;
|
|
390
|
+
if (code < 0x18) this._executeHandlersArr[code] = handler;
|
|
385
391
|
}
|
|
386
392
|
public clearExecuteHandler(flag: string): void {
|
|
387
|
-
|
|
393
|
+
const code = flag.charCodeAt(0);
|
|
394
|
+
if (this._executeHandlers[code]) delete this._executeHandlers[code];
|
|
395
|
+
if (code < 0x18) this._executeHandlersArr[code] = undefined;
|
|
388
396
|
}
|
|
389
397
|
public setExecuteHandlerFallback(handler: ExecuteFallbackHandlerType): void {
|
|
390
398
|
this._executeHandlerFb = handler;
|
|
@@ -462,8 +470,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
462
470
|
this._oscParser.reset();
|
|
463
471
|
this._dcsParser.reset();
|
|
464
472
|
this._apcParser.reset();
|
|
465
|
-
this._params.
|
|
466
|
-
this._params.addParam(0); // ZDM
|
|
473
|
+
this._params.resetZdm();
|
|
467
474
|
this._collect = 0;
|
|
468
475
|
this.precedingJoinState = 0;
|
|
469
476
|
// abort pending continuation from async handler
|
|
@@ -612,8 +619,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
612
619
|
return handlerResult;
|
|
613
620
|
}
|
|
614
621
|
if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE;
|
|
615
|
-
this._params.
|
|
616
|
-
this._params.addParam(0); // ZDM
|
|
622
|
+
this._params.resetZdm();
|
|
617
623
|
this._collect = 0;
|
|
618
624
|
break;
|
|
619
625
|
case ParserStackType.OSC:
|
|
@@ -623,8 +629,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
623
629
|
return handlerResult;
|
|
624
630
|
}
|
|
625
631
|
if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE;
|
|
626
|
-
this._params.
|
|
627
|
-
this._params.addParam(0); // ZDM
|
|
632
|
+
this._params.resetZdm();
|
|
628
633
|
this._collect = 0;
|
|
629
634
|
break;
|
|
630
635
|
case ParserStackType.APC:
|
|
@@ -634,8 +639,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
634
639
|
return handlerResult;
|
|
635
640
|
}
|
|
636
641
|
if (code === 0x1b) this._parseStack.transition |= ParserState.ESCAPE;
|
|
637
|
-
this._params.
|
|
638
|
-
this._params.addParam(0); // ZDM
|
|
642
|
+
this._params.resetZdm();
|
|
639
643
|
this._collect = 0;
|
|
640
644
|
break;
|
|
641
645
|
}
|
|
@@ -655,8 +659,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
655
659
|
|
|
656
660
|
// EXE fast-path: common control bytes (0x00-0x17) in non-payload states
|
|
657
661
|
if (code < 0x18 && this.currentState <= ParserState.CSI_IGNORE) {
|
|
658
|
-
|
|
659
|
-
else this._executeHandlerFb(code);
|
|
662
|
+
(this._executeHandlersArr[code] ?? this._executeHandlerFb)(code);
|
|
660
663
|
this.precedingJoinState = 0;
|
|
661
664
|
continue;
|
|
662
665
|
}
|
|
@@ -666,8 +669,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
666
669
|
&& this.currentState < ParserState.OSC_STRING
|
|
667
670
|
&& i + 2 < length && data[i + 1] === 0x5b
|
|
668
671
|
) {
|
|
669
|
-
this._params.
|
|
670
|
-
this._params.addParam(0); // ZDM
|
|
672
|
+
this._params.resetZdm();
|
|
671
673
|
this._collect = 0;
|
|
672
674
|
let k = i + 2;
|
|
673
675
|
let ch = data[k];
|
|
@@ -817,8 +819,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
817
819
|
this.precedingJoinState = 0;
|
|
818
820
|
break;
|
|
819
821
|
case ParserAction.CLEAR:
|
|
820
|
-
this._params.
|
|
821
|
-
this._params.addParam(0); // ZDM
|
|
822
|
+
this._params.resetZdm();
|
|
822
823
|
this._collect = 0;
|
|
823
824
|
break;
|
|
824
825
|
case ParserAction.DCS_HOOK:
|
|
@@ -842,8 +843,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
842
843
|
return handlerResult;
|
|
843
844
|
}
|
|
844
845
|
if (code === 0x1b) transition |= ParserState.ESCAPE;
|
|
845
|
-
this._params.
|
|
846
|
-
this._params.addParam(0); // ZDM
|
|
846
|
+
this._params.resetZdm();
|
|
847
847
|
this._collect = 0;
|
|
848
848
|
this.precedingJoinState = 0;
|
|
849
849
|
break;
|
|
@@ -867,8 +867,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
867
867
|
return handlerResult;
|
|
868
868
|
}
|
|
869
869
|
if (code === 0x1b) transition |= ParserState.ESCAPE;
|
|
870
|
-
this._params.
|
|
871
|
-
this._params.addParam(0); // ZDM
|
|
870
|
+
this._params.resetZdm();
|
|
872
871
|
this._collect = 0;
|
|
873
872
|
this.precedingJoinState = 0;
|
|
874
873
|
break;
|
|
@@ -892,8 +891,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
892
891
|
return handlerResult;
|
|
893
892
|
}
|
|
894
893
|
if (code === 0x1b) transition |= ParserState.ESCAPE;
|
|
895
|
-
this._params.
|
|
896
|
-
this._params.addParam(0); // ZDM
|
|
894
|
+
this._params.resetZdm();
|
|
897
895
|
this._collect = 0;
|
|
898
896
|
this.precedingJoinState = 0;
|
|
899
897
|
break;
|
|
@@ -129,6 +129,19 @@ export class Params implements IParams {
|
|
|
129
129
|
this._digitIsSub = false;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Reset and add 0 as first param (ZDM).
|
|
134
|
+
*/
|
|
135
|
+
public resetZdm(): void {
|
|
136
|
+
this.length = 1;
|
|
137
|
+
this._subParamsLength = 0;
|
|
138
|
+
this._rejectDigits = false;
|
|
139
|
+
this._rejectSubDigits = false;
|
|
140
|
+
this._digitIsSub = false;
|
|
141
|
+
this._subParamsIdx[0] = 0;
|
|
142
|
+
this.params[0] = 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
132
145
|
/**
|
|
133
146
|
* Add a parameter value.
|
|
134
147
|
* `Params` only stores up to `maxLength` parameters, any later
|
|
@@ -32,6 +32,7 @@ export interface IParams {
|
|
|
32
32
|
clone(): IParams;
|
|
33
33
|
toArray(): ParamsArray;
|
|
34
34
|
reset(): void;
|
|
35
|
+
resetZdm(): void;
|
|
35
36
|
addParam(value: number): void;
|
|
36
37
|
addSubParam(value: number): void;
|
|
37
38
|
hasSubParams(idx: number): boolean;
|
|
@@ -107,7 +108,7 @@ export type EscFallbackHandlerType = (identifier: number) => void;
|
|
|
107
108
|
/**
|
|
108
109
|
* EXECUTE handler types.
|
|
109
110
|
*/
|
|
110
|
-
export type ExecuteHandlerType = () => boolean;
|
|
111
|
+
export type ExecuteHandlerType = (ident?: number) => boolean;
|
|
111
112
|
export type ExecuteFallbackHandlerType = (ident: number) => void;
|
|
112
113
|
|
|
113
114
|
/**
|