xterm
[VSoRC/.git] / node_modules / xterm / src / common / services / BufferService.ts
1 /**
2  * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3  * @license MIT
4  */
5
6 import { IBufferService, IOptionsService } from 'common/services/Services';
7 import { BufferSet } from 'common/buffer/BufferSet';
8 import { IBufferSet, IBuffer } from 'common/buffer/Types';
9
10 export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
11 export const MINIMUM_ROWS = 1;
12
13 export class BufferService implements IBufferService {
14   serviceBrand: any;
15
16   public cols: number;
17   public rows: number;
18   public buffers: IBufferSet;
19
20   public get buffer(): IBuffer { return this.buffers.active; }
21
22   constructor(
23     @IOptionsService private _optionsService: IOptionsService
24   ) {
25     this.cols = Math.max(_optionsService.options.cols, MINIMUM_COLS);
26     this.rows = Math.max(_optionsService.options.rows, MINIMUM_ROWS);
27     this.buffers = new BufferSet(_optionsService, this);
28   }
29
30   public resize(cols: number, rows: number): void {
31     this.cols = cols;
32     this.rows = rows;
33   }
34
35   public reset(): void {
36     this.buffers = new BufferSet(this._optionsService, this);
37   }
38 }