Remove input handler Terminal.resize dep

This commit is contained in:
Daniel Imms
2020-04-26 06:34:36 -07:00
parent 451d9aab96
commit 3a1a0d6590
6 changed files with 23 additions and 21 deletions
+2 -2
View File
@@ -1741,7 +1741,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* through `options.windowsOptions`. * through `options.windowsOptions`.
*/ */
if (this._optionsService.options.windowOptions.setWinLines) { if (this._optionsService.options.windowOptions.setWinLines) {
this._terminal.resize(132, this._bufferService.rows); this._bufferService.resize(132, this._bufferService.rows);
this._onRequestReset.fire(); this._onRequestReset.fire();
} }
break; break;
@@ -1968,7 +1968,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* through `options.windowsOptions`. * through `options.windowsOptions`.
*/ */
if (this._optionsService.options.windowOptions.setWinLines) { if (this._optionsService.options.windowOptions.setWinLines) {
this._terminal.resize(80, this._bufferService.rows); this._bufferService.resize(80, this._bufferService.rows);
this._onRequestReset.fire(); this._onRequestReset.fire();
} }
break; break;
+6 -15
View File
@@ -47,7 +47,6 @@ import { ColorManager } from 'browser/ColorManager';
import { RenderService } from 'browser/services/RenderService'; import { RenderService } from 'browser/services/RenderService';
import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService } from 'browser/services/Services'; import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService } from 'browser/services/Services';
import { CharSizeService } from 'browser/services/CharSizeService'; import { CharSizeService } from 'browser/services/CharSizeService';
import { MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
import { IBuffer } from 'common/buffer/Types'; import { IBuffer } from 'common/buffer/Types';
import { MouseService } from 'browser/services/MouseService'; import { MouseService } from 'browser/services/MouseService';
import { IParams, IFunctionIdentifier } from 'common/parser/Types'; import { IParams, IFunctionIdentifier } from 'common/parser/Types';
@@ -155,6 +154,9 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT
this._setup(); this._setup();
// Setup listeners
this._bufferService.onResize(e => this._afterResize(e.cols, e.rows));
this._writeBuffer = new WriteBuffer(data => this._inputHandler.parse(data)); this._writeBuffer = new WriteBuffer(data => this._inputHandler.parse(data));
} }
@@ -1275,10 +1277,6 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT
* @param y The number of rows to resize to. * @param y The number of rows to resize to.
*/ */
public resize(x: number, y: number): void { public resize(x: number, y: number): void {
if (isNaN(x) || isNaN(y)) {
return;
}
if (x === this.cols && y === this.rows) { if (x === this.cols && y === this.rows) {
// Check if we still need to measure the char size (fixes #785). // Check if we still need to measure the char size (fixes #785).
if (this._charSizeService && !this._charSizeService.hasValidSize) { if (this._charSizeService && !this._charSizeService.hasValidSize) {
@@ -1287,22 +1285,15 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT
return; return;
} }
x = Math.max(x, MINIMUM_COLS); super.resize(x, y);
y = Math.max(y, MINIMUM_ROWS); }
this._bufferService.resize(x, y);
// TODO: Have charsize, viewport and renderservice depend on IBufferService.onResize?
private _afterResize(x: number, y: number): void {
this._charSizeService?.measure(); this._charSizeService?.measure();
// TODO: Call on resize event?
// Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an // Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an
// invalid location // invalid location
this.viewport?.syncScrollArea(true); this.viewport?.syncScrollArea(true);
// TODO: Move to renderservice
this.refresh(0, this.rows - 1);
} }
/** /**
-1
View File
@@ -24,7 +24,6 @@ export interface IInputHandlingTerminal {
viewport: IViewport; viewport: IViewport;
is(term: string): boolean; is(term: string): boolean;
resize(x: number, y: number): void;
} }
export interface ICompositionHelper { export interface ICompositionHelper {
+2 -2
View File
@@ -40,8 +40,7 @@ export class RenderService extends Disposable implements IRenderService {
screenElement: HTMLElement, screenElement: HTMLElement,
@IOptionsService optionsService: IOptionsService, @IOptionsService optionsService: IOptionsService,
@ICharSizeService charSizeService: ICharSizeService, @ICharSizeService charSizeService: ICharSizeService,
@IBufferService private readonly _bufferService: IBufferService, @IBufferService private readonly _bufferService: IBufferService
@ICoreService private readonly _coreService: ICoreService
) { ) {
super(); super();
this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end)); this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end));
@@ -51,6 +50,7 @@ export class RenderService extends Disposable implements IRenderService {
this._screenDprMonitor.setListener(() => this.onDevicePixelRatioChange()); this._screenDprMonitor.setListener(() => this.onDevicePixelRatioChange());
this.register(this._screenDprMonitor); this.register(this._screenDprMonitor);
this.register(this._bufferService.onResize(e => this._fullRefresh()));
this.register(optionsService.onOptionChange(() => this._renderer.onOptionsChanged())); this.register(optionsService.onOptionChange(() => this._renderer.onOptionsChanged()));
this.register(charSizeService.onCharSizeChange(() => this.onCharSizeChanged())); this.register(charSizeService.onCharSizeChange(() => this.onCharSizeChanged()));
+12 -1
View File
@@ -25,7 +25,7 @@ import { Disposable } from 'common/Lifecycle';
import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, IDirtyRowService } from 'common/services/Services'; import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, IDirtyRowService } from 'common/services/Services';
import { InstantiationService } from 'common/services/InstantiationService'; import { InstantiationService } from 'common/services/InstantiationService';
import { LogService } from 'common/services/LogService'; import { LogService } from 'common/services/LogService';
import { BufferService } from 'common/services/BufferService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
import { OptionsService } from 'common/services/OptionsService'; import { OptionsService } from 'common/services/OptionsService';
import { ITerminalOptions, IDisposable } from './Types'; import { ITerminalOptions, IDisposable } from './Types';
import { CoreService } from 'common/services/CoreService'; import { CoreService } from 'common/services/CoreService';
@@ -105,6 +105,17 @@ export abstract class CoreTerminal extends Disposable {
this._windowsMode = undefined; this._windowsMode = undefined;
} }
public resize(x: number, y: number): void {
if (isNaN(x) || isNaN(y)) {
return;
}
x = Math.max(x, MINIMUM_COLS);
y = Math.max(y, MINIMUM_ROWS);
this._bufferService.resize(x, y);
}
protected _setup(): void { protected _setup(): void {
if (this.optionsService.options.windowsMode) { if (this.optionsService.options.windowsMode) {
this._enableWindowsMode(); this._enableWindowsMode();
+1
View File
@@ -16,6 +16,7 @@ export class MockBufferService implements IBufferService {
public serviceBrand: any; public serviceBrand: any;
public get buffer(): IBuffer { return this.buffers.active; } public get buffer(): IBuffer { return this.buffers.active; }
public buffers: IBufferSet = {} as any; public buffers: IBufferSet = {} as any;
public onResize: IEvent<{ cols: number, rows: number }> = new EventEmitter<{ cols: number, rows: number }>().event;
constructor( constructor(
public cols: number, public cols: number,
public rows: number, public rows: number,