From 6ff4ae7194b266ce0a6fb29bfac645be76f3b1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Mon, 23 Apr 2018 22:06:24 +0200 Subject: [PATCH] revert to local const buffer --- src/Buffer.ts | 6 ++++-- src/InputHandler.ts | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Buffer.ts b/src/Buffer.ts index 0689c4cfa..c1cf3cc75 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -34,7 +34,6 @@ export class Buffer implements IBuffer { public savedY: number; public savedX: number; public markers: Marker[] = []; - public lines: CircularList; /** * Create a new Buffer. @@ -49,6 +48,10 @@ export class Buffer implements IBuffer { this.clear(); } + public get lines(): CircularList { + return this._lines; + } + public get hasScrollback(): boolean { return this._hasScrollback && this.lines.maxLength > this._terminal.rows; } @@ -95,7 +98,6 @@ export class Buffer implements IBuffer { this.y = 0; this.x = 0; this._lines = new CircularList(this._getCorrectBufferLength(this._terminal.rows)); - this.lines = this._lines; this.scrollTop = 0; this.scrollBottom = this._terminal.rows - 1; this.setupTabStops(); diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 3d39e0c0a..4df3e6955 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -39,22 +39,22 @@ export class InputHandler implements IInputHandler { this._terminal.emit('a11y.char', char); } - let row = buffer.lines.get(buffer.y + buffer.ybase); + let row = buffer.y + buffer.ybase; // insert combining char in last cell // FIXME: needs handling after cursor jumps if (!chWidth && buffer.x) { // dont overflow left - if (row[buffer.x - 1]) { - if (!row[buffer.x - 1][CHAR_DATA_WIDTH_INDEX]) { + if (buffer.lines.get(row)[buffer.x - 1]) { + if (!buffer.lines.get(row)[buffer.x - 1][CHAR_DATA_WIDTH_INDEX]) { // found empty cell after fullwidth, need to go 2 cells back - if (row[buffer.x - 2]) { - row[buffer.x - 2][CHAR_DATA_CHAR_INDEX] += char; - row[buffer.x - 2][3] = char.charCodeAt(0); + if (buffer.lines.get(row)[buffer.x - 2]) { + buffer.lines.get(row)[buffer.x - 2][CHAR_DATA_CHAR_INDEX] += char; + buffer.lines.get(row)[buffer.x - 2][3] = char.charCodeAt(0); } } else { - row[buffer.x - 1][CHAR_DATA_CHAR_INDEX] += char; - row[buffer.x - 1][3] = char.charCodeAt(0); + buffer.lines.get(row)[buffer.x - 1][CHAR_DATA_CHAR_INDEX] += char; + buffer.lines.get(row)[buffer.x - 1][3] = char.charCodeAt(0); } this._terminal.updateRange(buffer.y); } @@ -82,7 +82,7 @@ export class InputHandler implements IInputHandler { } } } - row = buffer.lines.get(buffer.y + buffer.ybase); + row = buffer.y + buffer.ybase; // insert mode: move characters to right if (this._terminal.insertMode) { @@ -92,23 +92,23 @@ export class InputHandler implements IInputHandler { // we have to adjust the second last cell as well const removed = buffer.lines.get(buffer.y + buffer.ybase).pop(); if (removed[CHAR_DATA_WIDTH_INDEX] === 0 - && row[this._terminal.cols - 2] - && row[this._terminal.cols - 2][CHAR_DATA_WIDTH_INDEX] === 2) { - row[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]; + && buffer.lines.get(row)[this._terminal.cols - 2] + && buffer.lines.get(row)[this._terminal.cols - 2][CHAR_DATA_WIDTH_INDEX] === 2) { + buffer.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]; } // insert empty cell at cursor - row.splice(buffer.x, 0, [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]); + buffer.lines.get(row).splice(buffer.x, 0, [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]); } } - row[buffer.x] = [this._terminal.curAttr, char, chWidth, char.charCodeAt(0)]; + buffer.lines.get(row)[buffer.x] = [this._terminal.curAttr, char, chWidth, char.charCodeAt(0)]; buffer.x++; this._terminal.updateRange(buffer.y); // fullwidth char - set next cell width to zero and advance cursor if (chWidth === 2) { - row[buffer.x] = [this._terminal.curAttr, '', 0, undefined]; + buffer.lines.get(row)[buffer.x] = [this._terminal.curAttr, '', 0, undefined]; buffer.x++; } }