Create new event with emitter object to simplify code

This commit is contained in:
Daniel Imms
2022-10-01 08:45:40 -07:00
parent 969db2bcf9
commit ed15a8e170
33 changed files with 247 additions and 307 deletions
+6 -8
View File
@@ -6,7 +6,7 @@
import { IBufferService, IOptionsService } from 'common/services/Services';
import { BufferSet } from 'common/buffer/BufferSet';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
import { EventEmitter, IEventEmitter, IEvent } from 'common/EventEmitter';
import { EventEmitter, IEventEmitter, IEvent, initEvent } from 'common/EventEmitter';
import { Disposable } from 'common/Lifecycle';
import { IAttributeData, IBufferLine, ScrollSource } from 'common/Types';
@@ -22,10 +22,8 @@ export class BufferService extends Disposable implements IBufferService {
/** Whether the user is scrolling (locks the scroll position) */
public isUserScrolling: boolean = false;
private readonly _onResize = new EventEmitter<{ cols: number, rows: number }>();
public readonly onResize = this._onResize.event;
private readonly _onScroll = new EventEmitter<number>();
public readonly onScroll = this._onScroll.event;
public readonly onResize = initEvent<{ cols: number, rows: number }>();
public readonly onScroll = initEvent<number>();
public get buffer(): IBuffer { return this.buffers.active; }
@@ -49,7 +47,7 @@ export class BufferService extends Disposable implements IBufferService {
this.rows = rows;
this.buffers.resize(cols, rows);
this.buffers.setupTabStops(this.cols);
this._onResize.fire({ cols, rows });
this.onResize.fire({ cols, rows });
}
public reset(): void {
@@ -118,7 +116,7 @@ export class BufferService extends Disposable implements IBufferService {
buffer.ydisp = buffer.ybase;
}
this._onScroll.fire(buffer.ydisp);
this.onScroll.fire(buffer.ydisp);
}
/**
@@ -148,7 +146,7 @@ export class BufferService extends Disposable implements IBufferService {
}
if (!suppressScrollEvent) {
this._onScroll.fire(buffer.ydisp);
this.onScroll.fire(buffer.ydisp);
}
}