Break input handler dep on Terminal.scroll

This commit is contained in:
Daniel Imms
2020-04-25 19:28:00 -07:00
parent 3897950e22
commit 0709b0dc3b
4 changed files with 7 additions and 15 deletions
+5 -3
View File
@@ -236,6 +236,8 @@ export class InputHandler extends Disposable implements IInputHandler {
public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }
private _onScroll = new EventEmitter<number>();
public get onScroll(): IEvent<number> { return this._onScroll.event; }
private _onScrollRequest = new EventEmitter<IAttributeData, boolean | void>();
public get onScrollRequest(): IEvent<IAttributeData, boolean | void> { return this._onScrollRequest.event; }
private _onTitleChange = new EventEmitter<string>();
public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; }
private _onA11yChar = new EventEmitter<string>();
@@ -554,7 +556,7 @@ export class InputHandler extends Disposable implements IInputHandler {
buffer.y++;
if (buffer.y === buffer.scrollBottom + 1) {
buffer.y--;
this._terminal.scroll(this._eraseAttrData(), true);
this._onScrollRequest.fire(this._eraseAttrData(), true);
} else {
if (buffer.y >= this._bufferService.rows) {
buffer.y = this._bufferService.rows - 1;
@@ -693,7 +695,7 @@ export class InputHandler extends Disposable implements IInputHandler {
buffer.y++;
if (buffer.y === buffer.scrollBottom + 1) {
buffer.y--;
this._terminal.scroll(this._eraseAttrData());
this._onScrollRequest.fire(this._eraseAttrData());
} else if (buffer.y >= this._bufferService.rows) {
buffer.y = this._bufferService.rows - 1;
}
@@ -2676,7 +2678,7 @@ export class InputHandler extends Disposable implements IInputHandler {
this._bufferService.buffer.y++;
if (buffer.y === buffer.scrollBottom + 1) {
buffer.y--;
this._terminal.scroll(this._eraseAttrData());
this._onScrollRequest.fire(this._eraseAttrData());
} else if (buffer.y >= this._bufferService.rows) {
buffer.y = this._bufferService.rows - 1;
}
+1
View File
@@ -180,6 +180,7 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT
this._inputHandler.onRequestBell(() => this.bell());
this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end));
this._inputHandler.onRequestReset(() => this.reset());
this._inputHandler.onScrollRequest((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined));
forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove);
forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed);
forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange);
-11
View File
@@ -14,7 +14,6 @@ import { Terminal } from './Terminal';
import { AttributeData } from 'common/buffer/AttributeData';
import { IColorManager, IColorSet, ILinkMatcherOptions, ILinkifier, IViewport, ILinkifier2 } from 'browser/Types';
import { IOptionsService, IUnicodeService } from 'common/services/Services';
import { EventEmitter } from 'common/EventEmitter';
import { IParams, IFunctionIdentifier } from 'common/parser/Types';
import { ISelectionService } from 'browser/services/Services';
@@ -198,23 +197,13 @@ export class MockTerminal implements ITerminal {
}
export class MockInputHandlingTerminal implements IInputHandlingTerminal {
public onA11yCharEmitter: EventEmitter<string>;
public onA11yTabEmitter: EventEmitter<number>;
public buffers: IBufferSet;
public buffer: IBuffer = new MockBuffer();
public viewport: IViewport;
public scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void {
throw new Error('Method not implemented.');
}
public is(term: string): boolean {
throw new Error('Method not implemented.');
}
public resize(x: number, y: number): void {
throw new Error('Method not implemented.');
}
public handler(data: string): void {
throw new Error('Method not implemented.');
}
}
export class MockBuffer implements IBuffer {
+1 -1
View File
@@ -23,7 +23,6 @@ export type LineData = CharData[];
export interface IInputHandlingTerminal {
viewport: IViewport;
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
is(term: string): boolean;
resize(x: number, y: number): void;
}
@@ -41,6 +40,7 @@ export interface ICompositionHelper {
*/
export interface IInputHandler {
onTitleChange: IEvent<string>;
onScrollRequest: IEvent<IAttributeData, boolean | void>;
parse(data: string | Uint8Array): void;
print(data: Uint32Array, start: number, end: number): void;