Move buffer/buffers ownership to BufferService

This commit is contained in:
Daniel Imms
2019-06-08 20:21:29 -07:00
parent c5c370801c
commit 09b0bbed32
6 changed files with 28 additions and 8 deletions
+7 -1
View File
@@ -3,7 +3,9 @@
* @license MIT
*/
import { IBufferService, IOptionsService } from './Services';
import { IBufferService, IOptionsService } from 'common/services/Services';
import { BufferSet } from 'common/buffer/BufferSet';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
export const MINIMUM_ROWS = 1;
@@ -11,12 +13,16 @@ export const MINIMUM_ROWS = 1;
export class BufferService implements IBufferService {
public cols: number;
public rows: number;
public buffers: IBufferSet;
public get buffer(): IBuffer { return this.buffers.active; }
constructor(
optionsService: IOptionsService
) {
this.cols = Math.max(optionsService.options.cols, MINIMUM_COLS);
this.rows = Math.max(optionsService.options.rows, MINIMUM_ROWS);
this.buffers = new BufferSet(optionsService, this);
}
public resize(cols: number, rows: number): void {
+3
View File
@@ -4,10 +4,13 @@
*/
import { IEvent } from 'common/EventEmitter2';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
export interface IBufferService {
readonly cols: number;
readonly rows: number;
readonly buffer: IBuffer;
readonly buffers: IBufferSet;
// TODO: Move resize event here