mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
fix member scope and tests
This commit is contained in:
@@ -11,6 +11,30 @@ function r(a: number, b: number): string[] {
|
||||
return arr;
|
||||
}
|
||||
|
||||
class TestEscapeSequenceParser extends EscapeSequenceParser {
|
||||
public get osc(): string {
|
||||
return this._osc;
|
||||
}
|
||||
public set osc(value: string) {
|
||||
this._osc = value;
|
||||
}
|
||||
public get params(): number[] {
|
||||
return this._params;
|
||||
}
|
||||
public set params(value: number[]) {
|
||||
this._params = value;
|
||||
}
|
||||
public get collect(): string {
|
||||
return this._collect;
|
||||
}
|
||||
public set collect(value: string) {
|
||||
this._collect = value;
|
||||
}
|
||||
public mockActiveDcsHandler(): void {
|
||||
this._activeDcsHandler = this._dcsHandlerFb;
|
||||
}
|
||||
}
|
||||
|
||||
let testTerminal: any = {
|
||||
calls: [],
|
||||
clear: function (): void {
|
||||
@@ -75,7 +99,7 @@ let states: number[] = [
|
||||
];
|
||||
let state: any;
|
||||
|
||||
let parser = new EscapeSequenceParser();
|
||||
let parser = new TestEscapeSequenceParser();
|
||||
parser.setPrintHandler(testTerminal.print.bind(testTerminal));
|
||||
parser.setCsiHandlerFallback((...params: any[]) => {
|
||||
testTerminal.actionCSI(params[0], params[1], String.fromCharCode(params[2]));
|
||||
@@ -872,6 +896,7 @@ describe('EscapeSequenceParser', function(): void {
|
||||
puts.concat(r(0x20, 0x7f));
|
||||
for (let i = 0; i < puts.length; ++i) {
|
||||
parser.currentState = ParserState.DCS_PASSTHROUGH;
|
||||
parser.mockActiveDcsHandler();
|
||||
parser.parse(puts[i]);
|
||||
chai.expect(parser.currentState).equal(ParserState.DCS_PASSTHROUGH);
|
||||
testTerminal.compare([['dcs put', puts[i]]]);
|
||||
|
||||
+15
-16
@@ -207,10 +207,9 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
public currentState: number;
|
||||
|
||||
// buffers over several parse calls
|
||||
// FIXME: make those protected (needs workaround in tests)
|
||||
public osc: string;
|
||||
public params: number[];
|
||||
public collect: string;
|
||||
protected _osc: string;
|
||||
protected _params: number[];
|
||||
protected _collect: string;
|
||||
|
||||
// handler lookup containers
|
||||
protected _printHandler: (data: string, start: number, end: number) => void;
|
||||
@@ -234,9 +233,9 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
constructor(readonly transitions: TransitionTable = VT500_TRANSITION_TABLE) {
|
||||
this.initialState = ParserState.GROUND;
|
||||
this.currentState = this.initialState;
|
||||
this.osc = '';
|
||||
this.params = [0];
|
||||
this.collect = '';
|
||||
this._osc = '';
|
||||
this._params = [0];
|
||||
this._collect = '';
|
||||
|
||||
// set default fallback handlers and handler lookup containers
|
||||
this._printHandlerFb = (data, start, end): void => { };
|
||||
@@ -325,9 +324,9 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
*/
|
||||
reset(): void {
|
||||
this.currentState = this.initialState;
|
||||
this.osc = '';
|
||||
this.params = [0];
|
||||
this.collect = '';
|
||||
this._osc = '';
|
||||
this._params = [0];
|
||||
this._collect = '';
|
||||
this._activeDcsHandler = null;
|
||||
}
|
||||
|
||||
@@ -342,9 +341,9 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
let currentState = this.currentState;
|
||||
let print = -1;
|
||||
let dcs = -1;
|
||||
let osc = this.osc;
|
||||
let collect = this.collect;
|
||||
let params = this.params;
|
||||
let osc = this._osc;
|
||||
let collect = this._collect;
|
||||
let params = this._params;
|
||||
const table: Uint8Array | number[] = this.transitions.table;
|
||||
let dcsHandler: IDcsHandler | null = this._activeDcsHandler;
|
||||
let callback: Function | null = null;
|
||||
@@ -529,9 +528,9 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
}
|
||||
|
||||
// save non pushable buffers
|
||||
this.osc = osc;
|
||||
this.collect = collect;
|
||||
this.params = params;
|
||||
this._osc = osc;
|
||||
this._collect = collect;
|
||||
this._params = params;
|
||||
|
||||
// save active dcs handler reference
|
||||
this._activeDcsHandler = dcsHandler;
|
||||
|
||||
Reference in New Issue
Block a user