]> git.proxmox.com Git - mirror_xterm.js.git/blame - src/BufferSet.ts
Start isolating buffer attributes into Buffer class
[mirror_xterm.js.git] / src / BufferSet.ts
CommitLineData
95cb6f30
PK
1/**
2 * @license MIT
3 */
4
5import { ITerminal } from './Interfaces';
6import { Buffer } from './Buffer';
8ede1fc9 7import { EventEmitter } from './EventEmitter';
95cb6f30 8
8ede1fc9 9export class BufferSet extends EventEmitter {
95cb6f30
PK
10 private _normal: Buffer;
11 private _alt: Buffer;
12 private _activeBuffer: Buffer;
13
14 constructor(private _terminal: ITerminal) {
8ede1fc9 15 super();
95cb6f30
PK
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;
bbafdd3d 41 this.resetTerminal();
8ede1fc9 42 this.emit('activate', this._normal);
95cb6f30
PK
43 }
44
45 public activateAltBuffer(): void {
8ede1fc9 46 this._activeBuffer = this._alt;
bbafdd3d 47 this.resetTerminal();
8ede1fc9 48 this.emit('activate', this._alt);
95cb6f30
PK
49 }
50}