]> git.proxmox.com Git - mirror_xterm.js.git/blob - src/BufferSet.ts
Start isolating buffer attributes into Buffer class
[mirror_xterm.js.git] / src / BufferSet.ts
1 /**
2 * @license MIT
3 */
4
5 import { ITerminal } from './Interfaces';
6 import { Buffer } from './Buffer';
7 import { EventEmitter } from './EventEmitter';
8
9 export class BufferSet extends EventEmitter {
10 private _normal: Buffer;
11 private _alt: Buffer;
12 private _activeBuffer: Buffer;
13
14 constructor(private _terminal: ITerminal) {
15 super();
16 this._normal = new Buffer(this._terminal);
17 this._alt = new Buffer(this._terminal);
18 this._activeBuffer = this._normal;
19 }
20
21 public get alt(): Buffer {
22 return this._alt;
23 }
24
25 public get active(): Buffer {
26 return this._activeBuffer;
27 }
28
29 public get normal(): Buffer {
30 return this._normal;
31 }
32
33 private resetTerminal() {
34 this._terminal.reset();
35 this._terminal.viewport.syncScrollArea();
36 this._terminal.showCursor();
37 }
38
39 public activateNormalBuffer(): void {
40 this._activeBuffer = this._normal;
41 this.resetTerminal();
42 this.emit('activate', this._normal);
43 }
44
45 public activateAltBuffer(): void {
46 this._activeBuffer = this._alt;
47 this.resetTerminal();
48 this.emit('activate', this._alt);
49 }
50 }