mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Some polish
This commit is contained in:
@@ -119,13 +119,13 @@ parser.setOscHandlerFallback((...params: any[]) => {
|
||||
if (params[0] === -1) testTerminal.actionOSC(params[1]); // handle error condition silently
|
||||
else testTerminal.actionOSC(params[0] + ';' + params[1]);
|
||||
});
|
||||
parser.setDcsHandlerFallback(new DcsTest);
|
||||
parser.setDcsHandlerFallback(new DcsTest());
|
||||
|
||||
|
||||
describe('EscapeSequenceParser', function (): void {
|
||||
describe('Parser init and methods', function (): void {
|
||||
it('constructor', function(): void {
|
||||
let p: EscapeSequenceParser = new EscapeSequenceParser;
|
||||
let p: EscapeSequenceParser = new EscapeSequenceParser();
|
||||
chai.expect(p.transitions).equal(VT500_TRANSITION_TABLE);
|
||||
p = new EscapeSequenceParser(VT500_TRANSITION_TABLE);
|
||||
chai.expect(p.transitions).equal(VT500_TRANSITION_TABLE);
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
|
||||
import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from './Types';
|
||||
|
||||
// number range macro
|
||||
function r(a: number, b: number): number[] {
|
||||
let c = b - a;
|
||||
/**
|
||||
* Returns an array fulled with numbers between the low and high parameters (inclusive).
|
||||
* @param low The low number.
|
||||
* @param high The high number.
|
||||
*/
|
||||
function r(low: number, high: number): number[] {
|
||||
let c = high - low;
|
||||
let arr = new Array(c);
|
||||
while (c--) {
|
||||
arr[c] = --b;
|
||||
arr[c] = --high;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
@@ -243,7 +247,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._csiHandlerFb = (...params: any[]): void => { };
|
||||
this._escHandlerFb = (...params: any[]): void => { };
|
||||
this._oscHandlerFb = (...params: any[]): void => { };
|
||||
this._dcsHandlerFb = new DcsDummy;
|
||||
this._dcsHandlerFb = new DcsDummy();
|
||||
this._errorHandlerFb = (state: IParsingState): IParsingState => state;
|
||||
this._printHandler = this._printHandlerFb;
|
||||
this._executeHandlers = Object.create(null);
|
||||
@@ -319,9 +323,6 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._errorHandler = this._errorHandlerFb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the parser.
|
||||
*/
|
||||
reset(): void {
|
||||
this.currentState = this.initialState;
|
||||
this._osc = '';
|
||||
@@ -330,10 +331,6 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._activeDcsHandler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse string `data`.
|
||||
* @param data
|
||||
*/
|
||||
parse(data: string): void {
|
||||
let code = 0;
|
||||
let transition = 0;
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { CharData, IInputHandler, IDcsHandler } from './Types';
|
||||
import { CharData, IInputHandler, IDcsHandler, IEscapeSequenceParser } from './Types';
|
||||
import { C0, C1 } from './EscapeSequences';
|
||||
import { CHARSETS, DEFAULT_CHARSET } from './Charsets';
|
||||
import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX } from './Buffer';
|
||||
@@ -112,7 +112,7 @@ export class InputHandler implements IInputHandler {
|
||||
|
||||
constructor(
|
||||
private _terminal: any,
|
||||
private _parser: EscapeSequenceParser = new EscapeSequenceParser)
|
||||
private _parser: IEscapeSequenceParser = new EscapeSequenceParser())
|
||||
{
|
||||
this._surrogateHigh = '';
|
||||
|
||||
|
||||
@@ -467,7 +467,15 @@ export interface IDcsHandler {
|
||||
* EscapeSequenceParser interface.
|
||||
*/
|
||||
export interface IEscapeSequenceParser {
|
||||
/**
|
||||
* Reset the parser to its initial state (handlers are kept).
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* Parse string `data`.
|
||||
* @param data The data to parse.
|
||||
*/
|
||||
parse(data: string): void;
|
||||
|
||||
setPrintHandler(callback: (data: string, start: number, end: number) => void): void;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"parameter"
|
||||
],
|
||||
"eofline": true,
|
||||
"new-parens": true,
|
||||
"no-duplicate-imports": true,
|
||||
"no-eval": true,
|
||||
"no-internal-module": true,
|
||||
|
||||
Reference in New Issue
Block a user