diff --git a/src/Buffer.ts b/src/Buffer.ts index ba147d8108..2164927ff5 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -11,13 +11,16 @@ export class Buffer { private _ydisp: number; private _y: number; private _x: number; - private _tabs: any; + private _tabs: any; // todo check applying custom tabs size to the alt buffer... + private _diff: number; // todo think about implementation + // Todo cursorHidden: boolean; todo seems should be moved to the buffer and restored after switching from alt buffer to normal buffer(and otherwise) => 1047, 47, 1049 in the InputHandler!!!! + // Todo cursorState: number; todo seems should be moved to the buffer and restored after switching from alt buffer to normal buffer(and otherwise) => 1047, 47, 1049 in the InputHandler!!!! constructor(private terminal: ITerminal) { this._lines = new CircularList(this.terminal.scrollback); } - public get lines(): CircularList { + public get lines(): CircularList { return this._lines; } } diff --git a/src/BufferSet.ts b/src/BufferSet.ts index e09ba96bf3..8a3388b5c6 100644 --- a/src/BufferSet.ts +++ b/src/BufferSet.ts @@ -1,16 +1,20 @@ /** * @license MIT + * @author Paris Kasidiaris + * paris@sourcelair.com */ import { ITerminal } from './Interfaces'; import { Buffer } from './Buffer'; +import {EventEmitter} from './EventEmitter'; -export class BufferSet { +export class BufferSet extends EventEmitter { private _normal: Buffer; private _alt: Buffer; private _activeBuffer: Buffer; constructor(private _terminal: ITerminal) { + super(); this._normal = new Buffer(this._terminal); this._alt = new Buffer(this._terminal); this._activeBuffer = this._normal; @@ -36,9 +40,13 @@ export class BufferSet { public activateNormalBuffer(): void { this._activeBuffer = this._normal; + this.resetTerminal(); + this.emit('activate', this._normal); } public activateAltBuffer(): void { this._activeBuffer = this._normal; + this.resetTerminal(); + this.emit('activate', this._normal); } } diff --git a/src/Interfaces.ts b/src/Interfaces.ts index 27dec3b884..ca1080644e 100644 --- a/src/Interfaces.ts +++ b/src/Interfaces.ts @@ -23,22 +23,25 @@ export interface ITerminal { selectionContainer: HTMLElement; charMeasure: ICharMeasure; textarea: HTMLTextAreaElement; - ybase: number; - ydisp: number; - normal: any; - lines: ICircularList; + ybase: number; // Todo should be deleted from here, because it will be used from buffer. @parisk part + ydisp: number; // Todo should be deleted from here, because it will be used from buffer. @parisk part + lines: ICircularList; // Todo should be moved to buffer at all!!! @parisk part rows: number; cols: number; - diff: number; + diff: number; // todo should be calculated and moved to the buffer, but how!!!!! browser: IBrowser; writeBuffer: string[]; children: HTMLElement[]; - cursorHidden: boolean; - cursorState: number; + cursorHidden: boolean; // todo seems should be moved to the buffer and restored after switching from alt buffer to normal buffer(and otherwise) => 1047, 47, 1049 in the InputHandler!!!! + cursorState: number; // todo seems should be moved to the buffer and restored after switching from alt buffer to normal buffer(and otherwise) => 1047, 47, 1049 in the InputHandler!!!! x: number; y: number; - defAttr: number; + defAttr: number; // todo hmm... check maybe it should be moved to the buffer and restored after switching from alt buffer to normal buffer(and otherwise) => 1047, 47, 1049 in the InputHandler!!!!? We need to find testcases to check this stuff, maybe it's will fixes some bugs with background colors or so on. scrollback: number; + // buffer and viewport @parisk changes. I need it. + buffer: any; // This should be a `Buffer` class, but it would result in circular dependency + // Todo we need think about it. Seems Alt buffer doesn't use scroll(in the xterm.js we uses ViewPort for alt screen, but I believe it's a mistake, which produces hard bugs.), so I'm not sure that we need scrollPort for alt buffer at all... But we exactly need it for normal buffer... Maybe this field should not be in the buffer and we need stay it in the ITerminal. + viewport: any; /** * Emit the 'data' event and populate the given data. @@ -51,6 +54,9 @@ export interface ITerminal { log(text: string): void; emit(event: string, data: any); blankLine(cur: any, isWrapped: boolean); // todo cur should be some array + // reset() and showCursor() @parisk changes. I need it. + reset(): void; + showCursor(): void; } export interface ISelectionManager {