mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Remove ITerminal usage in DECRQSS
This commit is contained in:
+10
-10
@@ -13,7 +13,7 @@ import { CellData } from 'common/buffer/CellData';
|
||||
import { Attributes } from 'common/buffer/Constants';
|
||||
import { AttributeData } from 'common/buffer/AttributeData';
|
||||
import { Params } from 'common/parser/Params';
|
||||
import { MockCoreService, MockBufferService } from 'common/TestUtils.test';
|
||||
import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test';
|
||||
import { IBufferService } from 'common/services/Services';
|
||||
|
||||
function getCursor(term: TestTerminal): number[] {
|
||||
@@ -31,7 +31,7 @@ describe('InputHandler', () => {
|
||||
bufferService.buffer.x = 1;
|
||||
bufferService.buffer.y = 2;
|
||||
bufferService.buffer.ybase = 0;
|
||||
const inputHandler = new InputHandler(terminal, bufferService, new MockCoreService());
|
||||
const inputHandler = new InputHandler(terminal, bufferService, new MockCoreService(), new MockOptionsService());
|
||||
// Save cursor position
|
||||
inputHandler.saveCursor();
|
||||
assert.equal(bufferService.buffer.x, 1);
|
||||
@@ -50,7 +50,7 @@ describe('InputHandler', () => {
|
||||
describe('setCursorStyle', () => {
|
||||
it('should call Terminal.setOption with correct params', () => {
|
||||
const terminal = new MockInputHandlingTerminal();
|
||||
const inputHandler = new InputHandler(terminal, new MockBufferService(80, 30), new MockCoreService());
|
||||
const inputHandler = new InputHandler(terminal, new MockBufferService(80, 30), new MockCoreService(), new MockOptionsService());
|
||||
const collect = ' ';
|
||||
|
||||
inputHandler.setCursorStyle(Params.fromArray([0]), collect);
|
||||
@@ -93,7 +93,7 @@ describe('InputHandler', () => {
|
||||
const terminal = new MockInputHandlingTerminal();
|
||||
const collect = '?';
|
||||
terminal.bracketedPasteMode = false;
|
||||
const inputHandler = new InputHandler(terminal, new MockBufferService(80, 30), new MockCoreService());
|
||||
const inputHandler = new InputHandler(terminal, new MockBufferService(80, 30), new MockCoreService(), new MockOptionsService());
|
||||
// Set bracketed paste mode
|
||||
inputHandler.setMode(Params.fromArray([2004]), collect);
|
||||
assert.equal(terminal.bracketedPasteMode, true);
|
||||
@@ -112,7 +112,7 @@ describe('InputHandler', () => {
|
||||
it('insertChars', function(): void {
|
||||
const term = new Terminal();
|
||||
const bufferService = new MockBufferService(80, 30);
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService());
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService(), new MockOptionsService());
|
||||
|
||||
// insert some data in first and second line
|
||||
inputHandler.parse(Array(bufferService.cols - 9).join('a'));
|
||||
@@ -150,7 +150,7 @@ describe('InputHandler', () => {
|
||||
it('deleteChars', function(): void {
|
||||
const term = new Terminal();
|
||||
const bufferService = new MockBufferService(80, 30);
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService());
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService(), new MockOptionsService());
|
||||
|
||||
// insert some data in first and second line
|
||||
inputHandler.parse(Array(bufferService.cols - 9).join('a'));
|
||||
@@ -191,7 +191,7 @@ describe('InputHandler', () => {
|
||||
it('eraseInLine', function(): void {
|
||||
const term = new Terminal();
|
||||
const bufferService = new MockBufferService(80, 30);
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService());
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService(), new MockOptionsService());
|
||||
|
||||
// fill 6 lines to test 3 different states
|
||||
inputHandler.parse(Array(bufferService.cols + 1).join('a'));
|
||||
@@ -220,7 +220,7 @@ describe('InputHandler', () => {
|
||||
it('eraseInDisplay', function(): void {
|
||||
const term = new Terminal({cols: 80, rows: 7});
|
||||
const bufferService = new MockBufferService(80, 7);
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService());
|
||||
const inputHandler = new InputHandler(term, bufferService, new MockCoreService(), new MockOptionsService());
|
||||
|
||||
// fill display with a's
|
||||
for (let i = 0; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a'));
|
||||
@@ -355,7 +355,7 @@ describe('InputHandler', () => {
|
||||
describe('print', () => {
|
||||
it('should not cause an infinite loop (regression test)', () => {
|
||||
const term = new Terminal();
|
||||
const inputHandler = new InputHandler(term, new MockBufferService(80, 30), new MockCoreService());
|
||||
const inputHandler = new InputHandler(term, new MockBufferService(80, 30), new MockCoreService(), new MockOptionsService());
|
||||
const container = new Uint32Array(10);
|
||||
container[0] = 0x200B;
|
||||
inputHandler.print(container, 0, 1);
|
||||
@@ -370,7 +370,7 @@ describe('InputHandler', () => {
|
||||
beforeEach(() => {
|
||||
term = new Terminal();
|
||||
bufferService = new MockBufferService(80, 30);
|
||||
handler = new InputHandler(term, bufferService, new MockCoreService());
|
||||
handler = new InputHandler(term, bufferService, new MockCoreService(), new MockOptionsService());
|
||||
});
|
||||
it('should handle DECSET/DECRST 47 (alt screen buffer)', () => {
|
||||
handler.parse('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST');
|
||||
|
||||
+16
-13
@@ -19,7 +19,7 @@ import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content
|
||||
import { CellData } from 'common/buffer/CellData';
|
||||
import { AttributeData } from 'common/buffer/AttributeData';
|
||||
import { IAttributeData, IDisposable } from 'common/Types';
|
||||
import { ICoreService, IBufferService } from 'common/services/Services';
|
||||
import { ICoreService, IBufferService, IOptionsService } from 'common/services/Services';
|
||||
import { ISelectionService } from 'browser/services/Services';
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,9 @@ class DECRQSS implements IDcsHandler {
|
||||
private _data: Uint32Array = new Uint32Array(0);
|
||||
|
||||
constructor(
|
||||
private _terminal: any,
|
||||
private _bufferService: IBufferService
|
||||
private _bufferService: IBufferService,
|
||||
private _coreService: ICoreService,
|
||||
private _optionsService: IOptionsService
|
||||
) { }
|
||||
|
||||
hook(collect: string, params: IParams, flag: number): void {
|
||||
@@ -60,25 +61,26 @@ class DECRQSS implements IDcsHandler {
|
||||
switch (data) {
|
||||
// valid: DCS 1 $ r Pt ST (xterm)
|
||||
case '"q': // DECSCA
|
||||
return this._terminal.handler(`${C0.ESC}P1$r0"q${C0.ESC}\\`);
|
||||
return this._coreService.triggerDataEvent(`${C0.ESC}P1$r0"q${C0.ESC}\\`);
|
||||
case '"p': // DECSCL
|
||||
return this._terminal.handler(`${C0.ESC}P1$r61"p${C0.ESC}\\`);
|
||||
return this._coreService.triggerDataEvent(`${C0.ESC}P1$r61"p${C0.ESC}\\`);
|
||||
case 'r': // DECSTBM
|
||||
const pt = '' + (this._bufferService.buffer.scrollTop + 1) +
|
||||
';' + (this._bufferService.buffer.scrollBottom + 1) + 'r';
|
||||
return this._terminal.handler(`${C0.ESC}P1$r${pt}${C0.ESC}\\`);
|
||||
return this._coreService.triggerDataEvent(`${C0.ESC}P1$r${pt}${C0.ESC}\\`);
|
||||
case 'm': // SGR
|
||||
// TODO: report real settings instead of 0m
|
||||
return this._terminal.handler(`${C0.ESC}P1$r0m${C0.ESC}\\`);
|
||||
return this._coreService.triggerDataEvent(`${C0.ESC}P1$r0m${C0.ESC}\\`);
|
||||
case ' q': // DECSCUSR
|
||||
const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6};
|
||||
let style = STYLES[this._terminal.getOption('cursorStyle')];
|
||||
style -= this._terminal.getOption('cursorBlink');
|
||||
return this._terminal.handler(`${C0.ESC}P1$r${style} q${C0.ESC}\\`);
|
||||
let style = STYLES[this._optionsService.options.cursorStyle];
|
||||
style -= this._optionsService.options.cursorBlink ? 1 : 0;
|
||||
return this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`);
|
||||
default:
|
||||
// invalid: DCS 0 $ r Pt ST (xterm)
|
||||
this._terminal.error('Unknown DCS $q %s', data);
|
||||
this._terminal.handler(`${C0.ESC}P0$r${C0.ESC}\\`);
|
||||
// TODO: Move this into a log service
|
||||
console.error('Unknown DCS $q %s', data);
|
||||
this._coreService.triggerDataEvent(`${C0.ESC}P0$r${C0.ESC}\\`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,6 +131,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
protected _terminal: IInputHandlingTerminal,
|
||||
private _bufferService: IBufferService,
|
||||
private _coreService: ICoreService,
|
||||
private _optionsService: IOptionsService,
|
||||
private _parser: IEscapeSequenceParser = new EscapeSequenceParser())
|
||||
{
|
||||
super();
|
||||
@@ -297,7 +300,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
/**
|
||||
* DCS handler
|
||||
*/
|
||||
this._parser.setDcsHandler('$q', new DECRQSS(this._terminal, this._bufferService));
|
||||
this._parser.setDcsHandler('$q', new DECRQSS(this._bufferService, this._coreService, this._optionsService));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
+1
-1
@@ -297,7 +297,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
this._userScrolling = false;
|
||||
|
||||
// Register input handler and refire/handle events
|
||||
this._inputHandler = new InputHandler(this, this._bufferService, this._coreService);
|
||||
this._inputHandler = new InputHandler(this, this._bufferService, this._coreService, this.optionsService);
|
||||
this._inputHandler.onCursorMove(() => this._onCursorMove.fire());
|
||||
this._inputHandler.onLineFeed(() => this._onLineFeed.fire());
|
||||
this.register(this._inputHandler);
|
||||
|
||||
Reference in New Issue
Block a user