revert to local const buffer

This commit is contained in:
Jörg Breitbart
2018-04-23 22:06:24 +02:00
parent 13d4ab6f8d
commit 6ff4ae7194
2 changed files with 19 additions and 17 deletions
+4 -2
View File
@@ -34,7 +34,6 @@ export class Buffer implements IBuffer {
public savedY: number;
public savedX: number;
public markers: Marker[] = [];
public lines: CircularList<LineData>;
/**
* Create a new Buffer.
@@ -49,6 +48,10 @@ export class Buffer implements IBuffer {
this.clear();
}
public get lines(): CircularList<LineData> {
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<LineData>(this._getCorrectBufferLength(this._terminal.rows));
this.lines = this._lines;
this.scrollTop = 0;
this.scrollBottom = this._terminal.rows - 1;
this.setupTabStops();
+15 -15
View File
@@ -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++;
}
}