Create terminal.buffer convenience attribute
This commit is contained in:
committed by
Paris Kasidiaris
parent
95cb6f30bb
commit
8ede1fc9d2
+35
-35
@@ -33,15 +33,15 @@ export class InputHandler implements IInputHandler {
|
||||
// FIXME: needs handling after cursor jumps
|
||||
if (!ch_width && this._terminal.x) {
|
||||
// dont overflow left
|
||||
if (this._terminal.lines.get(row)[this._terminal.x - 1]) {
|
||||
if (!this._terminal.lines.get(row)[this._terminal.x - 1][2]) {
|
||||
if (this._terminal.buffer.lines.get(row)[this._terminal.x - 1]) {
|
||||
if (!this._terminal.buffer.lines.get(row)[this._terminal.x - 1][2]) {
|
||||
|
||||
// found empty cell after fullwidth, need to go 2 cells back
|
||||
if (this._terminal.lines.get(row)[this._terminal.x - 2])
|
||||
this._terminal.lines.get(row)[this._terminal.x - 2][1] += char;
|
||||
if (this._terminal.buffer.lines.get(row)[this._terminal.x - 2])
|
||||
this._terminal.buffer.lines.get(row)[this._terminal.x - 2][1] += char;
|
||||
|
||||
} else {
|
||||
this._terminal.lines.get(row)[this._terminal.x - 1][1] += char;
|
||||
this._terminal.buffer.lines.get(row)[this._terminal.x - 1][1] += char;
|
||||
}
|
||||
this._terminal.updateRange(this._terminal.y);
|
||||
}
|
||||
@@ -77,25 +77,25 @@ export class InputHandler implements IInputHandler {
|
||||
for (let moves = 0; moves < ch_width; ++moves) {
|
||||
// remove last cell, if it's width is 0
|
||||
// we have to adjust the second last cell as well
|
||||
const removed = this._terminal.lines.get(this._terminal.y + this._terminal.ybase).pop();
|
||||
const removed = this._terminal.buffer.lines.get(this._terminal.y + this._terminal.ybase).pop();
|
||||
if (removed[2] === 0
|
||||
&& this._terminal.lines.get(row)[this._terminal.cols - 2]
|
||||
&& this._terminal.lines.get(row)[this._terminal.cols - 2][2] === 2) {
|
||||
this._terminal.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1];
|
||||
&& this._terminal.buffer.lines.get(row)[this._terminal.cols - 2]
|
||||
&& this._terminal.buffer.lines.get(row)[this._terminal.cols - 2][2] === 2) {
|
||||
this._terminal.buffer.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1];
|
||||
}
|
||||
|
||||
// insert empty cell at cursor
|
||||
this._terminal.lines.get(row).splice(this._terminal.x, 0, [this._terminal.curAttr, ' ', 1]);
|
||||
this._terminal.buffer.lines.get(row).splice(this._terminal.x, 0, [this._terminal.curAttr, ' ', 1]);
|
||||
}
|
||||
}
|
||||
|
||||
this._terminal.lines.get(row)[this._terminal.x] = [this._terminal.curAttr, char, ch_width];
|
||||
this._terminal.buffer.lines.get(row)[this._terminal.x] = [this._terminal.curAttr, char, ch_width];
|
||||
this._terminal.x++;
|
||||
this._terminal.updateRange(this._terminal.y);
|
||||
|
||||
// fullwidth char - set next cell width to zero and advance cursor
|
||||
if (ch_width === 2) {
|
||||
this._terminal.lines.get(row)[this._terminal.x] = [this._terminal.curAttr, '', 0];
|
||||
this._terminal.buffer.lines.get(row)[this._terminal.x] = [this._terminal.curAttr, '', 0];
|
||||
this._terminal.x++;
|
||||
}
|
||||
}
|
||||
@@ -194,8 +194,8 @@ export class InputHandler implements IInputHandler {
|
||||
ch = [this._terminal.eraseAttr(), ' ', 1]; // xterm
|
||||
|
||||
while (param-- && j < this._terminal.cols) {
|
||||
this._terminal.lines.get(row).splice(j++, 0, ch);
|
||||
this._terminal.lines.get(row).pop();
|
||||
this._terminal.buffer.lines.get(row).splice(j++, 0, ch);
|
||||
this._terminal.buffer.lines.get(row).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,9 +392,9 @@ export class InputHandler implements IInputHandler {
|
||||
break;
|
||||
case 3:
|
||||
// Clear scrollback (everything not in viewport)
|
||||
const scrollBackSize = this._terminal.lines.length - this._terminal.rows;
|
||||
const scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows;
|
||||
if (scrollBackSize > 0) {
|
||||
this._terminal.lines.trimStart(scrollBackSize);
|
||||
this._terminal.buffer.lines.trimStart(scrollBackSize);
|
||||
this._terminal.ybase = Math.max(this._terminal.ybase - scrollBackSize, 0);
|
||||
this._terminal.ydisp = Math.max(this._terminal.ydisp - scrollBackSize, 0);
|
||||
// Force a scroll event to refresh viewport
|
||||
@@ -446,9 +446,9 @@ export class InputHandler implements IInputHandler {
|
||||
j = this._terminal.rows - 1 + this._terminal.ybase - j + 1;
|
||||
|
||||
while (param--) {
|
||||
if (this._terminal.lines.length === this._terminal.lines.maxLength) {
|
||||
if (this._terminal.buffer.lines.length === this._terminal.buffer.lines.maxLength) {
|
||||
// Trim the start of lines to make room for the new line
|
||||
this._terminal.lines.trimStart(1);
|
||||
this._terminal.buffer.lines.trimStart(1);
|
||||
this._terminal.ybase--;
|
||||
this._terminal.ydisp--;
|
||||
row--;
|
||||
@@ -456,8 +456,8 @@ export class InputHandler implements IInputHandler {
|
||||
}
|
||||
// test: echo -e '\e[44m\e[1L\e[0m'
|
||||
// blankLine(true) - xterm/linux behavior
|
||||
this._terminal.lines.splice(row, 0, this._terminal.blankLine(true));
|
||||
this._terminal.lines.splice(j, 1);
|
||||
this._terminal.buffer.lines.splice(row, 0, this._terminal.blankLine(true));
|
||||
this._terminal.buffer.lines.splice(j, 1);
|
||||
}
|
||||
|
||||
// this.maxRange();
|
||||
@@ -482,16 +482,16 @@ export class InputHandler implements IInputHandler {
|
||||
j = this._terminal.rows - 1 + this._terminal.ybase - j;
|
||||
|
||||
while (param--) {
|
||||
if (this._terminal.lines.length === this._terminal.lines.maxLength) {
|
||||
if (this._terminal.buffer.lines.length === this._terminal.buffer.lines.maxLength) {
|
||||
// Trim the start of lines to make room for the new line
|
||||
this._terminal.lines.trimStart(1);
|
||||
this._terminal.buffer.lines.trimStart(1);
|
||||
this._terminal.ybase -= 1;
|
||||
this._terminal.ydisp -= 1;
|
||||
}
|
||||
// test: echo -e '\e[44m\e[1M\e[0m'
|
||||
// blankLine(true) - xterm/linux behavior
|
||||
this._terminal.lines.splice(j + 1, 0, this._terminal.blankLine(true));
|
||||
this._terminal.lines.splice(row, 1);
|
||||
this._terminal.buffer.lines.splice(j + 1, 0, this._terminal.blankLine(true));
|
||||
this._terminal.buffer.lines.splice(row, 1);
|
||||
}
|
||||
|
||||
// this.maxRange();
|
||||
@@ -515,8 +515,8 @@ export class InputHandler implements IInputHandler {
|
||||
ch = [this._terminal.eraseAttr(), ' ', 1]; // xterm
|
||||
|
||||
while (param--) {
|
||||
this._terminal.lines.get(row).splice(this._terminal.x, 1);
|
||||
this._terminal.lines.get(row).push(ch);
|
||||
this._terminal.buffer.lines.get(row).splice(this._terminal.x, 1);
|
||||
this._terminal.buffer.lines.get(row).push(ch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,8 +526,8 @@ export class InputHandler implements IInputHandler {
|
||||
public scrollUp(params: number[]): void {
|
||||
let param = params[0] || 1;
|
||||
while (param--) {
|
||||
this._terminal.lines.splice(this._terminal.ybase + this._terminal.scrollTop, 1);
|
||||
this._terminal.lines.splice(this._terminal.ybase + this._terminal.scrollBottom, 0, this._terminal.blankLine());
|
||||
this._terminal.buffer.lines.splice(this._terminal.ybase + this._terminal.scrollTop, 1);
|
||||
this._terminal.buffer.lines.splice(this._terminal.ybase + this._terminal.scrollBottom, 0, this._terminal.blankLine());
|
||||
}
|
||||
// this.maxRange();
|
||||
this._terminal.updateRange(this._terminal.scrollTop);
|
||||
@@ -540,8 +540,8 @@ export class InputHandler implements IInputHandler {
|
||||
public scrollDown(params: number[]): void {
|
||||
let param = params[0] || 1;
|
||||
while (param--) {
|
||||
this._terminal.lines.splice(this._terminal.ybase + this._terminal.scrollBottom, 1);
|
||||
this._terminal.lines.splice(this._terminal.ybase + this._terminal.scrollTop, 0, this._terminal.blankLine());
|
||||
this._terminal.buffer.lines.splice(this._terminal.ybase + this._terminal.scrollBottom, 1);
|
||||
this._terminal.buffer.lines.splice(this._terminal.ybase + this._terminal.scrollTop, 0, this._terminal.blankLine());
|
||||
}
|
||||
// this.maxRange();
|
||||
this._terminal.updateRange(this._terminal.scrollTop);
|
||||
@@ -565,7 +565,7 @@ export class InputHandler implements IInputHandler {
|
||||
ch = [this._terminal.eraseAttr(), ' ', 1]; // xterm
|
||||
|
||||
while (param-- && j < this._terminal.cols) {
|
||||
this._terminal.lines.get(row)[j++] = ch;
|
||||
this._terminal.buffer.lines.get(row)[j++] = ch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ export class InputHandler implements IInputHandler {
|
||||
*/
|
||||
public repeatPrecedingCharacter(params: number[]): void {
|
||||
let param = params[0] || 1
|
||||
, line = this._terminal.lines.get(this._terminal.ybase + this._terminal.y)
|
||||
, line = this._terminal.buffer.lines.get(this._terminal.ybase + this._terminal.y)
|
||||
, ch = line[this._terminal.x - 1] || [this._terminal.defAttr, ' ', 1];
|
||||
|
||||
while (param--) {
|
||||
@@ -949,7 +949,7 @@ export class InputHandler implements IInputHandler {
|
||||
case 1047: // alt screen buffer
|
||||
if (!this._terminal.normal) {
|
||||
let normal = {
|
||||
lines: this._terminal.lines,
|
||||
lines: this._terminal.buffers.normal.lines,
|
||||
ybase: this._terminal.ybase,
|
||||
ydisp: this._terminal.ydisp,
|
||||
x: this._terminal.x,
|
||||
@@ -1128,7 +1128,7 @@ export class InputHandler implements IInputHandler {
|
||||
case 47: // normal screen buffer
|
||||
case 1047: // normal screen buffer - clearing it first
|
||||
if (this._terminal.normal) {
|
||||
this._terminal.lines = this._terminal.normal.lines;
|
||||
this._terminal.buffers.activateNormalBuffer();
|
||||
this._terminal.ybase = this._terminal.normal.ybase;
|
||||
this._terminal.ydisp = this._terminal.normal.ydisp;
|
||||
this._terminal.x = this._terminal.normal.x;
|
||||
@@ -1138,7 +1138,7 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.tabs = this._terminal.normal.tabs;
|
||||
this._terminal.normal = null;
|
||||
// Ensure the selection manager has the correct buffer
|
||||
this._terminal.selectionManager.setBuffer(this._terminal.lines);
|
||||
this._terminal.selectionManager.setBuffer(this._terminal.buffer.lines);
|
||||
// if (params === 1049) {
|
||||
// this.x = this.savedX;
|
||||
// this.y = this.savedY;
|
||||
|
||||
Reference in New Issue
Block a user