mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
multiple changes in InputHandler:
- remove prefix/postfix - optional collect arg where needed - tempPrefix handler removed - replaced .bind with () => notation - moved callback registering to ctor again
This commit is contained in:
@@ -91,8 +91,6 @@ parser.setOscHandlerFallback((...params: any[]) => {
|
||||
else testTerminal.actionOSC(params[0] + ';' + params[1]);
|
||||
});
|
||||
parser.setDcsHandlerFallback(new DcsTest);
|
||||
// FIXME: to be removed
|
||||
parser.setPrefixHandler(() => {});
|
||||
|
||||
|
||||
describe('EscapeSequenceParser', function(): void {
|
||||
|
||||
+13
-26
@@ -3,11 +3,7 @@
|
||||
* - docs
|
||||
* - extend test cases
|
||||
*/
|
||||
import {
|
||||
ParserState, ParserAction, IParsingState, IPrintHandler,
|
||||
IExecuteHandler, ICsiHandler, IEscHandler, IOscHandler,
|
||||
IDcsHandler, IErrorHandler, IEscapeSequenceParser
|
||||
} from './Types';
|
||||
import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from './Types';
|
||||
|
||||
// number range macro
|
||||
function r(a: number, b: number): number[] {
|
||||
@@ -213,26 +209,23 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
public collect: string;
|
||||
|
||||
// callback slots
|
||||
protected _printHandler: IPrintHandler;
|
||||
protected _printHandler: (data: string, start: number, end: number) => void;
|
||||
protected _executeHandlers: any;
|
||||
protected _csiHandlers: any;
|
||||
protected _escHandlers: any;
|
||||
protected _oscHandlers: any;
|
||||
protected _dcsHandlers: any;
|
||||
protected _activeDcsHandler: IDcsHandler | null;
|
||||
protected _errorHandler: IErrorHandler;
|
||||
protected _errorHandler: (state: IParsingState) => IParsingState;
|
||||
|
||||
// fallback handlers
|
||||
protected _printHandlerFb: IPrintHandler;
|
||||
protected _printHandlerFb: (data: string, start: number, end: number) => void;
|
||||
protected _executeHandlerFb: (...params: any[]) => void;
|
||||
protected _csiHandlerFb: (...params: any[]) => void;
|
||||
protected _escHandlerFb: (...params: any[]) => void;
|
||||
protected _oscHandlerFb: (...params: any[]) => void;
|
||||
protected _dcsHandlerFb: IDcsHandler;
|
||||
protected _errorHandlerFb: IErrorHandler;
|
||||
|
||||
// FIXME: to be removed
|
||||
protected _tempPrefixHandler: any;
|
||||
protected _errorHandlerFb: (state: IParsingState) => IParsingState;
|
||||
|
||||
constructor(transitions: TransitionTable = VT500_TRANSITION_TABLE) {
|
||||
this.initialState = ParserState.GROUND;
|
||||
@@ -260,14 +253,14 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._errorHandler = this._errorHandlerFb;
|
||||
}
|
||||
|
||||
setPrintHandler(callback: IPrintHandler): void {
|
||||
setPrintHandler(callback: (data: string, start: number, end: number) => void): void {
|
||||
this._printHandler = callback;
|
||||
}
|
||||
clearPrintHandler(): void {
|
||||
this._printHandler = this._printHandlerFb;
|
||||
}
|
||||
|
||||
setExecuteHandler(flag: string, callback: IExecuteHandler): void {
|
||||
setExecuteHandler(flag: string, callback: () => void): void {
|
||||
this._executeHandlers[flag.charCodeAt(0)] = callback;
|
||||
}
|
||||
clearExecuteHandler(flag: string): void {
|
||||
@@ -277,7 +270,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._executeHandlerFb = callback;
|
||||
}
|
||||
|
||||
setCsiHandler(flag: string, callback: ICsiHandler): void {
|
||||
setCsiHandler(flag: string, callback: (params: number[], collect: string) => void): void {
|
||||
this._csiHandlers[flag.charCodeAt(0)] = callback;
|
||||
}
|
||||
clearCsiHandler(flag: string): void {
|
||||
@@ -287,7 +280,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._csiHandlerFb = callback;
|
||||
}
|
||||
|
||||
setEscHandler(collect: string, flag: string, callback: IEscHandler): void {
|
||||
setEscHandler(collect: string, flag: string, callback: (collect: string, flag: number) => void): void {
|
||||
this._escHandlers[collect + flag] = callback;
|
||||
}
|
||||
clearEscHandler(collect: string, flag: string): void {
|
||||
@@ -297,7 +290,7 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._escHandlerFb = callback;
|
||||
}
|
||||
|
||||
setOscHandler(ident: number, callback: IOscHandler): void {
|
||||
setOscHandler(ident: number, callback: (data: string) => void): void {
|
||||
this._oscHandlers[ident] = callback;
|
||||
}
|
||||
clearOscHandler(ident: number): void {
|
||||
@@ -317,18 +310,13 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
this._dcsHandlerFb = handler;
|
||||
}
|
||||
|
||||
setErrorHandler(callback: IErrorHandler): void {
|
||||
setErrorHandler(callback: (state: IParsingState) => IParsingState): void {
|
||||
this._errorHandler = callback;
|
||||
}
|
||||
clearErrorHandler(): void {
|
||||
this._errorHandler = this._errorHandlerFb;
|
||||
}
|
||||
|
||||
// FIXME: to be removed
|
||||
setPrefixHandler(callback: (collect: string) => void): void {
|
||||
this._tempPrefixHandler = callback;
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.currentState = this.initialState;
|
||||
this.osc = '';
|
||||
@@ -397,8 +385,8 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
}
|
||||
break;
|
||||
case ParserAction.ERROR:
|
||||
// chars higher than 0x9f are handled by this action to
|
||||
// keep the lookup table small
|
||||
// chars higher than 0x9f are handled by this action
|
||||
// to keep the transition table small
|
||||
if (code > 0x9f) {
|
||||
switch (currentState) {
|
||||
case ParserState.GROUND:
|
||||
@@ -444,7 +432,6 @@ export class EscapeSequenceParser implements IEscapeSequenceParser {
|
||||
}
|
||||
break;
|
||||
case ParserAction.CSI_DISPATCH:
|
||||
this._tempPrefixHandler(collect); // FIXME: to be removed
|
||||
if (this._csiHandlers[code]) this._csiHandlers[code](params, collect);
|
||||
else this._csiHandlerFb(collect, params, code);
|
||||
break;
|
||||
|
||||
@@ -68,14 +68,14 @@ describe('InputHandler', () => {
|
||||
describe('setMode', () => {
|
||||
it('should toggle Terminal.bracketedPasteMode', () => {
|
||||
let terminal = new MockInputHandlingTerminal();
|
||||
terminal.prefix = '?';
|
||||
const collect = '?';
|
||||
terminal.bracketedPasteMode = false;
|
||||
let inputHandler = new InputHandler(terminal);
|
||||
// Set bracketed paste mode
|
||||
inputHandler.setMode([2004]);
|
||||
inputHandler.setMode([2004], collect);
|
||||
assert.equal(terminal.bracketedPasteMode, true);
|
||||
// Reset bracketed paste mode
|
||||
inputHandler.resetMode([2004]);
|
||||
inputHandler.resetMode([2004], collect);
|
||||
assert.equal(terminal.bracketedPasteMode, false);
|
||||
});
|
||||
});
|
||||
|
||||
+68
-73
@@ -23,10 +23,7 @@ export class InputHandler implements IInputHandler {
|
||||
private _parser: EscapeSequenceParser;
|
||||
private _surrogateHigh: string;
|
||||
|
||||
constructor(protected _terminal: any) { }
|
||||
|
||||
// FIXME: temp workaround to get tests working again
|
||||
init(): void {
|
||||
constructor(protected _terminal: any) {
|
||||
this._parser = new EscapeSequenceParser; // FIXME: maybe as ctor argument
|
||||
this._surrogateHigh = '';
|
||||
|
||||
@@ -44,49 +41,47 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.error('Unknown OSC code: ', params);
|
||||
});
|
||||
|
||||
// FIXME: remove temporary fix to get collect to terminal
|
||||
this._parser.setPrefixHandler((collect: string) => { this._terminal.prefix = collect; });
|
||||
|
||||
// print handler
|
||||
this._parser.setPrintHandler(this.print.bind(this));
|
||||
this._parser.setPrintHandler(
|
||||
(data: string, start: number, end: number): void => this.print(data, start, end));
|
||||
|
||||
// CSI handler
|
||||
this._parser.setCsiHandler('@', this.insertChars.bind(this));
|
||||
this._parser.setCsiHandler('A', this.cursorUp.bind(this));
|
||||
this._parser.setCsiHandler('B', this.cursorDown.bind(this));
|
||||
this._parser.setCsiHandler('C', this.cursorForward.bind(this));
|
||||
this._parser.setCsiHandler('D', this.cursorBackward.bind(this));
|
||||
this._parser.setCsiHandler('E', this.cursorNextLine.bind(this));
|
||||
this._parser.setCsiHandler('F', this.cursorPrecedingLine.bind(this));
|
||||
this._parser.setCsiHandler('G', this.cursorCharAbsolute.bind(this));
|
||||
this._parser.setCsiHandler('H', this.cursorPosition.bind(this));
|
||||
this._parser.setCsiHandler('I', this.cursorForwardTab.bind(this));
|
||||
this._parser.setCsiHandler('J', this.eraseInDisplay.bind(this));
|
||||
this._parser.setCsiHandler('K', this.eraseInLine.bind(this));
|
||||
this._parser.setCsiHandler('L', this.insertLines.bind(this));
|
||||
this._parser.setCsiHandler('M', this.deleteLines.bind(this));
|
||||
this._parser.setCsiHandler('P', this.deleteChars.bind(this));
|
||||
this._parser.setCsiHandler('S', this.scrollUp.bind(this));
|
||||
this._parser.setCsiHandler('@', (params, collect) => this.insertChars(params));
|
||||
this._parser.setCsiHandler('A', (params, collect) => this.cursorUp(params));
|
||||
this._parser.setCsiHandler('B', (params, collect) => this.cursorDown(params));
|
||||
this._parser.setCsiHandler('C', (params, collect) => this.cursorForward(params));
|
||||
this._parser.setCsiHandler('D', (params, collect) => this.cursorBackward(params));
|
||||
this._parser.setCsiHandler('E', (params, collect) => this.cursorNextLine(params));
|
||||
this._parser.setCsiHandler('F', (params, collect) => this.cursorPrecedingLine(params));
|
||||
this._parser.setCsiHandler('G', (params, collect) => this.cursorCharAbsolute(params));
|
||||
this._parser.setCsiHandler('H', (params, collect) => this.cursorPosition(params));
|
||||
this._parser.setCsiHandler('I', (params, collect) => this.cursorForwardTab(params));
|
||||
this._parser.setCsiHandler('J', (params, collect) => this.eraseInDisplay(params));
|
||||
this._parser.setCsiHandler('K', (params, collect) => this.eraseInLine(params));
|
||||
this._parser.setCsiHandler('L', (params, collect) => this.insertLines(params));
|
||||
this._parser.setCsiHandler('M', (params, collect) => this.deleteLines(params));
|
||||
this._parser.setCsiHandler('P', (params, collect) => this.deleteChars(params));
|
||||
this._parser.setCsiHandler('S', (params, collect) => this.scrollUp(params));
|
||||
this._parser.setCsiHandler('T',
|
||||
(params, collect) => {
|
||||
if (params.length < 2 && !collect) {
|
||||
return this.scrollDown(params);
|
||||
}
|
||||
});
|
||||
this._parser.setCsiHandler('X', this.eraseChars.bind(this));
|
||||
this._parser.setCsiHandler('Z', this.cursorBackwardTab.bind(this));
|
||||
this._parser.setCsiHandler('`', this.charPosAbsolute.bind(this));
|
||||
this._parser.setCsiHandler('a', this.HPositionRelative.bind(this));
|
||||
this._parser.setCsiHandler('b', this.repeatPrecedingCharacter.bind(this));
|
||||
this._parser.setCsiHandler('c', this.sendDeviceAttributes.bind(this)); // fix collect
|
||||
this._parser.setCsiHandler('d', this.linePosAbsolute.bind(this));
|
||||
this._parser.setCsiHandler('e', this.VPositionRelative.bind(this));
|
||||
this._parser.setCsiHandler('f', this.HVPosition.bind(this));
|
||||
this._parser.setCsiHandler('g', this.tabClear.bind(this));
|
||||
this._parser.setCsiHandler('h', this.setMode.bind(this)); // fix collect
|
||||
this._parser.setCsiHandler('l', this.resetMode.bind(this)); // fix collect
|
||||
this._parser.setCsiHandler('m', this.charAttributes.bind(this));
|
||||
this._parser.setCsiHandler('n', this.deviceStatus.bind(this)); // fix collect
|
||||
this._parser.setCsiHandler('X', (params, collect) => this.eraseChars(params));
|
||||
this._parser.setCsiHandler('Z', (params, collect) => this.cursorBackwardTab(params));
|
||||
this._parser.setCsiHandler('`', (params, collect) => this.charPosAbsolute(params));
|
||||
this._parser.setCsiHandler('a', (params, collect) => this.HPositionRelative(params));
|
||||
this._parser.setCsiHandler('b', (params, collect) => this.repeatPrecedingCharacter(params));
|
||||
this._parser.setCsiHandler('c', (params, collect) => this.sendDeviceAttributes(params, collect));
|
||||
this._parser.setCsiHandler('d', (params, collect) => this.linePosAbsolute(params));
|
||||
this._parser.setCsiHandler('e', (params, collect) => this.VPositionRelative(params));
|
||||
this._parser.setCsiHandler('f', (params, collect) => this.HVPosition(params));
|
||||
this._parser.setCsiHandler('g', (params, collect) => this.tabClear(params));
|
||||
this._parser.setCsiHandler('h', (params, collect) => this.setMode(params, collect));
|
||||
this._parser.setCsiHandler('l', (params, collect) => this.resetMode(params, collect));
|
||||
this._parser.setCsiHandler('m', (params, collect) => this.charAttributes(params, collect));
|
||||
this._parser.setCsiHandler('n', (params, collect) => this.deviceStatus(params, collect));
|
||||
this._parser.setCsiHandler('p',
|
||||
(params, collect) => {
|
||||
if (collect === '!') {
|
||||
@@ -99,29 +94,29 @@ export class InputHandler implements IInputHandler {
|
||||
return this.setCursorStyle(params);
|
||||
}
|
||||
});
|
||||
this._parser.setCsiHandler('r', this.setScrollRegion.bind(this)); // fix collect
|
||||
this._parser.setCsiHandler('s', this.saveCursor.bind(this));
|
||||
this._parser.setCsiHandler('u', this.restoreCursor.bind(this));
|
||||
this._parser.setCsiHandler('r', (params, collect) => this.setScrollRegion(params, collect));
|
||||
this._parser.setCsiHandler('s', (params, collect) => this.saveCursor(params));
|
||||
this._parser.setCsiHandler('u', (params, collect) => this.restoreCursor(params));
|
||||
|
||||
// execute handler
|
||||
this._parser.setExecuteHandler(C0.BEL, this.bell.bind(this));
|
||||
this._parser.setExecuteHandler(C0.LF, this.lineFeed.bind(this));
|
||||
this._parser.setExecuteHandler(C0.VT, this.lineFeed.bind(this));
|
||||
this._parser.setExecuteHandler(C0.FF, this.lineFeed.bind(this));
|
||||
this._parser.setExecuteHandler(C0.CR, this.carriageReturn.bind(this));
|
||||
this._parser.setExecuteHandler(C0.BS, this.backspace.bind(this));
|
||||
this._parser.setExecuteHandler(C0.HT, this.tab.bind(this));
|
||||
this._parser.setExecuteHandler(C0.SO, this.shiftOut.bind(this));
|
||||
this._parser.setExecuteHandler(C0.SI, this.shiftIn.bind(this));
|
||||
this._parser.setExecuteHandler(C0.BEL, () => this.bell());
|
||||
this._parser.setExecuteHandler(C0.LF, () => this.lineFeed());
|
||||
this._parser.setExecuteHandler(C0.VT, () => this.lineFeed());
|
||||
this._parser.setExecuteHandler(C0.FF, () => this.lineFeed());
|
||||
this._parser.setExecuteHandler(C0.CR, () => this.carriageReturn());
|
||||
this._parser.setExecuteHandler(C0.BS, () => this.backspace());
|
||||
this._parser.setExecuteHandler(C0.HT, () => this.tab());
|
||||
this._parser.setExecuteHandler(C0.SO, () => this.shiftOut());
|
||||
this._parser.setExecuteHandler(C0.SI, () => this.shiftIn());
|
||||
// FIXME: What do to with missing? Old code just added those to print, but that's wrong
|
||||
// behavior for most control codes.
|
||||
|
||||
// OSC handler
|
||||
// 0 - icon name + title
|
||||
this._parser.setOscHandler(0, this._terminal.handleTitle.bind(this._terminal));
|
||||
this._parser.setOscHandler(0, (data) => this._terminal.handleTitle(data));
|
||||
// 1 - icon name
|
||||
// 2 - title
|
||||
this._parser.setOscHandler(2, this._terminal.handleTitle.bind(this._terminal));
|
||||
this._parser.setOscHandler(2, (data) => this._terminal.handleTitle(data));
|
||||
// 3 - set property X in the form "prop=value"
|
||||
// 4 - Change Color Number
|
||||
// 5 - Change Special Color Number
|
||||
@@ -156,15 +151,15 @@ export class InputHandler implements IInputHandler {
|
||||
// 119 - Reset highlight foreground color.
|
||||
|
||||
// ESC handlers
|
||||
this._parser.setEscHandler('', '7', this.saveCursor.bind(this));
|
||||
this._parser.setEscHandler('', '8', this.restoreCursor.bind(this));
|
||||
this._parser.setEscHandler('', 'D', this._terminal.index.bind(this._terminal));
|
||||
this._parser.setEscHandler('', '7', () => this.saveCursor([])); // fix args
|
||||
this._parser.setEscHandler('', '8', () => this.restoreCursor([])); // fix args
|
||||
this._parser.setEscHandler('', 'D', () => this._terminal.index());
|
||||
this._parser.setEscHandler('', 'E', () => {
|
||||
this._terminal.buffer.x = 0;
|
||||
this._terminal.index();
|
||||
});
|
||||
this._parser.setEscHandler('', 'H', this._terminal.tabSet.bind(this._terminal));
|
||||
this._parser.setEscHandler('', 'M', this._terminal.reverseIndex.bind(this._terminal));
|
||||
this._parser.setEscHandler('', 'H', () => this._terminal.tabSet());
|
||||
this._parser.setEscHandler('', 'M', () => this._terminal.reverseIndex());
|
||||
this._parser.setEscHandler('', '=', () => {
|
||||
this._terminal.log('Serial port requested application keypad.');
|
||||
this._terminal.applicationKeypad = true;
|
||||
@@ -179,7 +174,7 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.viewport.syncScrollArea();
|
||||
}
|
||||
});
|
||||
this._parser.setEscHandler('', 'c', this._terminal.reset.bind(this._terminal));
|
||||
this._parser.setEscHandler('', 'c', () => this._terminal.reset());
|
||||
this._parser.setEscHandler('', 'n', () => this._terminal.setgLevel(2));
|
||||
this._parser.setEscHandler('', 'o', () => this._terminal.setgLevel(3));
|
||||
this._parser.setEscHandler('', '|', () => this._terminal.setgLevel(3));
|
||||
@@ -918,18 +913,18 @@ export class InputHandler implements IInputHandler {
|
||||
* xterm/charproc.c - line 2012, for more information.
|
||||
* vim responds with ^[[?0c or ^[[?1c after the terminal's response (?)
|
||||
*/
|
||||
public sendDeviceAttributes(params: number[]): void {
|
||||
public sendDeviceAttributes(params: number[], collect?: string): void {
|
||||
if (params[0] > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._terminal.prefix) {
|
||||
if (!collect) {
|
||||
if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {
|
||||
this._terminal.send(C0.ESC + '[?1;2c');
|
||||
} else if (this._terminal.is('linux')) {
|
||||
this._terminal.send(C0.ESC + '[?6c');
|
||||
}
|
||||
} else if (this._terminal.prefix === '>') {
|
||||
} else if (collect === '>') {
|
||||
// xterm and urxvt
|
||||
// seem to spit this
|
||||
// out around ~370 times (?).
|
||||
@@ -1105,7 +1100,7 @@ export class InputHandler implements IInputHandler {
|
||||
* Modes:
|
||||
* http: *vt100.net/docs/vt220-rm/chapter4.html
|
||||
*/
|
||||
public setMode(params: number[]): void {
|
||||
public setMode(params: number[], collect?: string): void {
|
||||
if (params.length > 1) {
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
this.setMode([params[i]]);
|
||||
@@ -1114,7 +1109,7 @@ export class InputHandler implements IInputHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._terminal.prefix) {
|
||||
if (!collect) {
|
||||
switch (params[0]) {
|
||||
case 4:
|
||||
this._terminal.insertMode = true;
|
||||
@@ -1123,7 +1118,7 @@ export class InputHandler implements IInputHandler {
|
||||
// this._t.convertEol = true;
|
||||
break;
|
||||
}
|
||||
} else if (this._terminal.prefix === '?') {
|
||||
} else if (collect === '?') {
|
||||
switch (params[0]) {
|
||||
case 1:
|
||||
this._terminal.applicationCursor = true;
|
||||
@@ -1299,7 +1294,7 @@ export class InputHandler implements IInputHandler {
|
||||
* Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.
|
||||
* Ps = 2 0 0 4 -> Reset bracketed paste mode.
|
||||
*/
|
||||
public resetMode(params: number[]): void {
|
||||
public resetMode(params: number[], collect?: string): void {
|
||||
if (params.length > 1) {
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
this.resetMode([params[i]]);
|
||||
@@ -1308,7 +1303,7 @@ export class InputHandler implements IInputHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._terminal.prefix) {
|
||||
if (!collect) {
|
||||
switch (params[0]) {
|
||||
case 4:
|
||||
this._terminal.insertMode = false;
|
||||
@@ -1317,7 +1312,7 @@ export class InputHandler implements IInputHandler {
|
||||
// this._t.convertEol = false;
|
||||
break;
|
||||
}
|
||||
} else if (this._terminal.prefix === '?') {
|
||||
} else if (collect === '?') {
|
||||
switch (params[0]) {
|
||||
case 1:
|
||||
this._terminal.applicationCursor = false;
|
||||
@@ -1454,7 +1449,7 @@ export class InputHandler implements IInputHandler {
|
||||
* Ps = 4 8 ; 5 ; Ps -> Set background color to the second
|
||||
* Ps.
|
||||
*/
|
||||
public charAttributes(params: number[]): void {
|
||||
public charAttributes(params: number[], collect?: string): void {
|
||||
// Optimize a single SGR0.
|
||||
if (params.length === 1 && params[0] === 0) {
|
||||
this._terminal.curAttr = this._terminal.defAttr;
|
||||
@@ -1597,8 +1592,8 @@ export class InputHandler implements IInputHandler {
|
||||
* CSI ? 5 3 n Locator available, if compiled-in, or
|
||||
* CSI ? 5 0 n No Locator, if not.
|
||||
*/
|
||||
public deviceStatus(params: number[]): void {
|
||||
if (!this._terminal.prefix) {
|
||||
public deviceStatus(params: number[], collect?: string): void {
|
||||
if (!collect) {
|
||||
switch (params[0]) {
|
||||
case 5:
|
||||
// status report
|
||||
@@ -1613,7 +1608,7 @@ export class InputHandler implements IInputHandler {
|
||||
+ 'R');
|
||||
break;
|
||||
}
|
||||
} else if (this._terminal.prefix === '?') {
|
||||
} else if (collect === '?') {
|
||||
// modern xterm doesnt seem to
|
||||
// respond to any of these except ?6, 6, and 5
|
||||
switch (params[0]) {
|
||||
@@ -1702,8 +1697,8 @@ export class InputHandler implements IInputHandler {
|
||||
* dow) (DECSTBM).
|
||||
* CSI ? Pm r
|
||||
*/
|
||||
public setScrollRegion(params: number[]): void {
|
||||
if (this._terminal.prefix) return;
|
||||
public setScrollRegion(params: number[], collect?: string): void {
|
||||
if (collect) return;
|
||||
this._terminal.buffer.scrollTop = (params[0] || 1) - 1;
|
||||
this._terminal.buffer.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;
|
||||
this._terminal.buffer.x = 0;
|
||||
|
||||
@@ -193,8 +193,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
|
||||
public params: (string | number)[];
|
||||
public currentParam: string | number;
|
||||
public prefix: string;
|
||||
public postfix: string;
|
||||
|
||||
// user input states
|
||||
public writeBuffer: string[];
|
||||
@@ -318,8 +316,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
|
||||
this.params = [];
|
||||
this.currentParam = 0;
|
||||
this.prefix = '';
|
||||
this.postfix = '';
|
||||
|
||||
// user input states
|
||||
this.writeBuffer = [];
|
||||
@@ -330,7 +326,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
this._userScrolling = false;
|
||||
|
||||
this._inputHandler = new InputHandler(this);
|
||||
this._inputHandler.init();
|
||||
// Reuse renderer if the Terminal is being recreated via a reset call.
|
||||
this.renderer = this.renderer || null;
|
||||
this.selectionManager = this.selectionManager || null;
|
||||
|
||||
+6
-61
@@ -45,7 +45,6 @@ export interface IInputHandlingTerminal extends IEventEmitter {
|
||||
bracketedPasteMode: boolean;
|
||||
defAttr: number;
|
||||
curAttr: number;
|
||||
prefix: string;
|
||||
savedCols: number;
|
||||
x10Mouse: boolean;
|
||||
vt200Mouse: boolean;
|
||||
@@ -427,50 +426,6 @@ export interface IParsingState {
|
||||
abort: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print handler signature for EscapeSequenceParser.
|
||||
* `start` and `end` are the start and end indices of
|
||||
* printable characters in `data`.
|
||||
*/
|
||||
export interface IPrintHandler {
|
||||
(data: string, start: number, end: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute handler signature for EscapeSequenceParser.
|
||||
*/
|
||||
export interface IExecuteHandler {
|
||||
(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* CSI handler signature for EscapeSequenceParser.
|
||||
* `collect` contains the intermediate characters
|
||||
* of the escape sequence.
|
||||
*/
|
||||
export interface ICsiHandler {
|
||||
(params: number[], collect: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* ESC handler signature for EscapeSequenceParser.
|
||||
* `collect` contains the intermediate characters
|
||||
* of the escape sequence. `flag` is the final
|
||||
* character as character code.
|
||||
*/
|
||||
export interface IEscHandler {
|
||||
(collect: string, flag: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* OSC handler signature for EscapeSequenceParser.
|
||||
* `data` contains all characters right of the first ;
|
||||
* example: OSC 123;foo=bar;baz\007 --> 'foo=bar;baz'
|
||||
*/
|
||||
export interface IOscHandler {
|
||||
(data: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* DCS handler signature for EscapeSequenceParser.
|
||||
* EscapeSequenceParser handles DCS commands via separate
|
||||
@@ -483,13 +438,6 @@ export interface IDcsHandler {
|
||||
unhook(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler signature for EscapeSequenceParser.
|
||||
*/
|
||||
export interface IErrorHandler {
|
||||
(state: IParsingState): IParsingState;
|
||||
}
|
||||
|
||||
/**
|
||||
* EscapeSequenceParser interface.
|
||||
*/
|
||||
@@ -497,22 +445,22 @@ export interface IEscapeSequenceParser {
|
||||
reset(): void;
|
||||
parse(data: string): void;
|
||||
|
||||
setPrintHandler(callback: IPrintHandler): void;
|
||||
setPrintHandler(callback: (data: string, start: number, end: number) => void): void;
|
||||
clearPrintHandler(): void;
|
||||
|
||||
setExecuteHandler(flag: string, callback: IExecuteHandler): void;
|
||||
setExecuteHandler(flag: string, callback: () => void): void;
|
||||
clearExecuteHandler(flag: string): void;
|
||||
setExecuteHandlerFallback(callback: (...params: any[]) => void): void;
|
||||
|
||||
setCsiHandler(flag: string, callback: ICsiHandler): void;
|
||||
setCsiHandler(flag: string, callback: (params: number[], collect: string) => void): void;
|
||||
clearCsiHandler(flag: string): void;
|
||||
setCsiHandlerFallback(callback: (...params: any[]) => void): void;
|
||||
|
||||
setEscHandler(collect: string, flag: string, callback: IEscHandler): void;
|
||||
setEscHandler(collect: string, flag: string, callback: (collect: string, flag: number) => void): void;
|
||||
clearEscHandler(collect: string, flag: string): void;
|
||||
setEscHandlerFallback(callback: (...params: any[]) => void): void;
|
||||
|
||||
setOscHandler(ident: number, callback: IOscHandler): void;
|
||||
setOscHandler(ident: number, callback: (data: string) => void): void;
|
||||
clearOscHandler(ident: number): void;
|
||||
setOscHandlerFallback(callback: (...params: any[]) => void): void;
|
||||
|
||||
@@ -520,9 +468,6 @@ export interface IEscapeSequenceParser {
|
||||
clearDcsHandler(collect: string, flag: string): void;
|
||||
setDcsHandlerFallback(handler: IDcsHandler): void;
|
||||
|
||||
setErrorHandler(callback: IErrorHandler): void;
|
||||
setErrorHandler(callback: (state: IParsingState) => IParsingState): void;
|
||||
clearErrorHandler(): void;
|
||||
|
||||
// remove after revamp of InputHandler methods
|
||||
setPrefixHandler(callback: (collect: string) => void): void;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,6 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal {
|
||||
bracketedPasteMode: boolean;
|
||||
defAttr: number;
|
||||
curAttr: number;
|
||||
prefix: string;
|
||||
savedCols: number;
|
||||
x10Mouse: boolean;
|
||||
vt200Mouse: boolean;
|
||||
|
||||
Reference in New Issue
Block a user