Properly setup and maintain tab stops for the alt buffer

Fixes #930
This commit is contained in:
Daniel Imms
2017-08-29 21:08:11 -07:00
parent 38c66e7c1a
commit a57e511fa3
6 changed files with 68 additions and 49 deletions
+2 -43
View File
@@ -392,8 +392,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
if (this.selectionManager) {
this.selectionManager.setBuffer(this.buffer);
}
this.setupStops();
}
/**
@@ -486,7 +484,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.buffers.resize(this.cols, this.rows);
this.viewport.syncScrollArea();
break;
case 'tabStopWidth': this.setupStops(); break;
case 'tabStopWidth': this.buffers.setupTabStops(); break;
case 'bellSound':
case 'bellStyle': this.syncBellSound(); break;
}
@@ -1938,7 +1936,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.cols = x;
this.rows = y;
this.setupStops(this.cols);
this.buffers.setupTabStops(this.cols);
this.charMeasure.measure();
@@ -1971,45 +1969,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.refreshEnd = this.rows - 1;
}
/**
* Setup the tab stops.
* @param {number} i
*/
public setupStops(i?: number): void {
if (i != null) {
if (!this.buffer.tabs[i]) {
i = this.prevStop(i);
}
} else {
this.buffer.tabs = {};
i = 0;
}
for (; i < this.cols; i += this.getOption('tabStopWidth')) {
this.buffer.tabs[i] = true;
}
}
/**
* Move the cursor to the previous tab stop from the given position (default is current).
* @param {number} x The position to move the cursor to the previous tab stop.
*/
public prevStop(x?: number): number {
if (x == null) x = this.buffer.x;
while (!this.buffer.tabs[--x] && x > 0);
return x >= this.cols ? this.cols - 1 : x < 0 ? 0 : x;
}
/**
* Move the cursor one tab stop forward from the given position (default is current).
* @param {number} x The position to move the cursor one tab stop forward.
*/
public nextStop(x?: number): number {
if (x == null) x = this.buffer.x;
while (!this.buffer.tabs[++x] && x < this.cols);
return x >= this.cols ? this.cols - 1 : x < 0 ? 0 : x;
}
/**
* Erase in the identified line everything from "x" to the end of the line (right).
* @param {number} x The column from which to start erasing to the end of the line.