Move resize event into bufferservice

This commit is contained in:
Daniel Imms
2020-04-26 06:16:13 -07:00
parent eba372e2cc
commit a6949d522e
4 changed files with 18 additions and 9 deletions
+6 -3
View File
@@ -29,7 +29,7 @@ import { BufferService } from 'common/services/BufferService';
import { OptionsService } from 'common/services/OptionsService';
import { ITerminalOptions, IDisposable } from './Types';
import { CoreService } from 'common/services/CoreService';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
import { CoreMouseService } from 'common/services/CoreMouseService';
import { DirtyRowService } from 'common/services/DirtyRowService';
import { UnicodeService } from 'common/services/UnicodeService';
@@ -58,6 +58,8 @@ export abstract class CoreTerminal extends Disposable {
public get onData(): IEvent<string> { return this._onData.event; }
protected _onLineFeed = new EventEmitter<void>();
public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
public get cols(): number { return this._bufferService.cols; }
public get rows(): number { return this._bufferService.rows; }
@@ -88,8 +90,9 @@ export abstract class CoreTerminal extends Disposable {
this._instantiationService.setService(ICharsetService, this._charsetService);
// Setup listeners
this._coreService.onData(e => this._onData.fire(e));
this._coreService.onBinary(e => this._onBinary.fire(e));
forwardEvent(this._bufferService.onResize, this._onResize);
forwardEvent(this._coreService.onData, this._onData);
forwardEvent(this._coreService.onBinary, this._onBinary);
this.optionsService.onOptionChange(key => this._updateOptions(key));
}
+5
View File
@@ -6,6 +6,7 @@
import { IBufferService, IOptionsService } from 'common/services/Services';
import { BufferSet } from 'common/buffer/BufferSet';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
import { EventEmitter, IEvent } from 'common/EventEmitter';
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
export const MINIMUM_ROWS = 1;
@@ -17,6 +18,9 @@ export class BufferService implements IBufferService {
public rows: number;
public buffers: IBufferSet;
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
public get buffer(): IBuffer { return this.buffers.active; }
constructor(
@@ -32,6 +36,7 @@ export class BufferService implements IBufferService {
this.rows = rows;
this.buffers.resize(cols, rows);
this.buffers.setupTabStops(this.cols);
this._onResize.fire({ cols, rows });
}
public reset(): void {
+1 -1
View File
@@ -17,7 +17,7 @@ export interface IBufferService {
readonly buffer: IBuffer;
readonly buffers: IBufferSet;
// TODO: Move resize event here
onResize: IEvent<{ cols: number, rows: number }>;
resize(cols: number, rows: number): void;
reset(): void;