Introduce new Buffer and BufferSet classes
This commit is contained in:
committed by
Paris Kasidiaris
parent
c94fdaecb2
commit
95cb6f30bb
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ITerminal } from './Interfaces';
|
||||||
|
import { CircularList } from './utils/CircularList';
|
||||||
|
|
||||||
|
export class Buffer {
|
||||||
|
private _lines: CircularList<any>;
|
||||||
|
private _ybase: number;
|
||||||
|
private _ydisp: number;
|
||||||
|
private _y: number;
|
||||||
|
private _x: number;
|
||||||
|
private _tabs: any;
|
||||||
|
|
||||||
|
constructor(private terminal: ITerminal) {
|
||||||
|
this._lines = new CircularList(this.terminal.scrollback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get lines(): CircularList {
|
||||||
|
return this._lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ITerminal } from './Interfaces';
|
||||||
|
import { Buffer } from './Buffer';
|
||||||
|
|
||||||
|
export class BufferSet {
|
||||||
|
private _normal: Buffer;
|
||||||
|
private _alt: Buffer;
|
||||||
|
private _activeBuffer: Buffer;
|
||||||
|
|
||||||
|
constructor(private _terminal: ITerminal) {
|
||||||
|
this._normal = new Buffer(this._terminal);
|
||||||
|
this._alt = new Buffer(this._terminal);
|
||||||
|
this._activeBuffer = this._normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get alt(): Buffer {
|
||||||
|
return this._alt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get active(): Buffer {
|
||||||
|
return this._activeBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get normal(): Buffer {
|
||||||
|
return this._normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private resetTerminal() {
|
||||||
|
this._terminal.reset();
|
||||||
|
this._terminal.viewport.syncScrollArea();
|
||||||
|
this._terminal.showCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public activateNormalBuffer(): void {
|
||||||
|
this._activeBuffer = this._normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public activateAltBuffer(): void {
|
||||||
|
this._activeBuffer = this._normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ export interface ITerminal {
|
|||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
defAttr: number;
|
defAttr: number;
|
||||||
|
scrollback: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emit the 'data' event and populate the given data.
|
* Emit the 'data' event and populate the given data.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { BufferSet } from './BufferSet';
|
||||||
import { CompositionHelper } from './CompositionHelper';
|
import { CompositionHelper } from './CompositionHelper';
|
||||||
import { EventEmitter } from './EventEmitter';
|
import { EventEmitter } from './EventEmitter';
|
||||||
import { Viewport } from './Viewport';
|
import { Viewport } from './Viewport';
|
||||||
@@ -243,6 +244,7 @@ function Terminal(options) {
|
|||||||
// leftover surrogate high from previous write invocation
|
// leftover surrogate high from previous write invocation
|
||||||
this.surrogate_high = '';
|
this.surrogate_high = '';
|
||||||
|
|
||||||
|
this.buffers = new BufferSet(this);
|
||||||
/**
|
/**
|
||||||
* An array of all lines in the entire buffer, including the prompt. The lines are array of
|
* An array of all lines in the entire buffer, including the prompt. The lines are array of
|
||||||
* characters which are 2-length arrays where [0] is an attribute and [1] is the character.
|
* characters which are 2-length arrays where [0] is an attribute and [1] is the character.
|
||||||
|
|||||||
Reference in New Issue
Block a user