5 import { ITerminal, IBufferSet } from './Interfaces';
6 import { Buffer } from './Buffer';
7 import { EventEmitter } from './EventEmitter';
10 * The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and
11 * provides also utilities for working with them.
13 export class BufferSet extends EventEmitter implements IBufferSet {
14 private _normal: Buffer;
16 private _activeBuffer: Buffer;
19 * Create a new BufferSet for the given terminal.
20 * @param {Terminal} terminal - The terminal the BufferSet will belong to
22 constructor(private _terminal: ITerminal) {
24 this._normal = new Buffer(this._terminal);
25 this._alt = new Buffer(this._terminal);
26 this._activeBuffer = this._normal;
30 * Returns the alt Buffer of the BufferSet
33 public get alt(): Buffer {
38 * Returns the normal Buffer of the BufferSet
41 public get active(): Buffer {
42 return this._activeBuffer;
46 * Returns the currently active Buffer of the BufferSet
49 public get normal(): Buffer {
54 * Sets the normal Buffer of the BufferSet as its currently active Buffer
56 public activateNormalBuffer(): void {
57 this._activeBuffer = this._normal;
58 this.emit('activate', this._normal);
62 * Sets the alt Buffer of the BufferSet as its currently active Buffer
64 public activateAltBuffer(): void {
65 this._activeBuffer = this._alt;
66 this.emit('activate', this._alt);