Merge branch 'master' into 642_link_wrapped_char_duplication

This commit is contained in:
Daniel Imms
2017-06-13 14:45:17 -07:00
committed by GitHub
4 changed files with 35 additions and 12 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ export class InputHandler implements IInputHandler {
this._terminal.y++;
if (this._terminal.y > this._terminal.scrollBottom) {
this._terminal.y--;
this._terminal.scroll();
this._terminal.scroll(true);
}
} else {
if (ch_width === 2) // FIXME: check for xterm behavior
+4 -5
View File
@@ -353,9 +353,8 @@ export class Renderer {
const endCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : this._terminal.cols;
documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));
// Draw middle rows
for (let i = viewportCappedStartRow + 1; i < viewportCappedEndRow; i++) {
documentFragment.appendChild(this._createSelectionElement(i, 0, this._terminal.cols));
}
const middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;
documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._terminal.cols, middleRowsCount));
// Draw final row
if (viewportCappedStartRow !== viewportCappedEndRow) {
// Only draw viewportEndRow if it's not the same as viewporttartRow
@@ -371,9 +370,9 @@ export class Renderer {
* @param colStart The start column.
* @param colEnd The end columns.
*/
private _createSelectionElement(row: number, colStart: number, colEnd: number): HTMLElement {
private _createSelectionElement(row: number, colStart: number, colEnd: number, rowCount: number = 1): HTMLElement {
const element = document.createElement('div');
element.style.height = `${this._terminal.charMeasure.height}px`;
element.style.height = `${rowCount * this._terminal.charMeasure.height}px`;
element.style.top = `${row * this._terminal.charMeasure.height}px`;
element.style.left = `${colStart * this._terminal.charMeasure.width}px`;
element.style.width = `${this._terminal.charMeasure.width * (colEnd - colStart)}px`;
+17 -2
View File
@@ -180,12 +180,24 @@ export class SelectionManager extends EventEmitter {
// Get middle rows
for (let i = start[1] + 1; i <= end[1] - 1; i++) {
result.push(this._translateBufferLineToString(this._buffer.get(i), true));
const bufferLine = this._buffer.get(i);
const lineText = this._translateBufferLineToString(bufferLine, true);
if (bufferLine.isWrapped) {
result[result.length - 1] += lineText;
} else {
result.push(lineText);
}
}
// Get final row
if (start[1] !== end[1]) {
result.push(this._translateBufferLineToString(this._buffer.get(end[1]), true, 0, end[0]));
const bufferLine = this._buffer.get(end[1]);
const lineText = this._translateBufferLineToString(bufferLine, true, 0, end[0]);
if (bufferLine.isWrapped) {
result[result.length - 1] += lineText;
} else {
result.push(lineText);
}
}
// Format string by replacing non-breaking space chars with regular spaces
@@ -336,6 +348,9 @@ export class SelectionManager extends EventEmitter {
return;
}
// Tell the browser not to start a regular selection
event.preventDefault();
// Reset drag scroll state
this._dragScrollAmount = 0;
+13 -4
View File
@@ -1117,8 +1117,10 @@ Terminal.prototype.showCursor = function() {
/**
* Scroll the terminal down 1 row, creating a blank line.
* @param {boolean} isWrapped Whether the new line is wrapped from the previous
* line.
*/
Terminal.prototype.scroll = function() {
Terminal.prototype.scroll = function(isWrapped) {
var row;
// Make room for the new row in lines
@@ -1145,10 +1147,10 @@ Terminal.prototype.scroll = function() {
if (row === this.lines.length) {
// Optimization: pushing is faster than splicing when they amount to the same behavior
this.lines.push(this.blankLine());
this.lines.push(this.blankLine(undefined, isWrapped));
} else {
// add our new line
this.lines.splice(row, 0, this.blankLine());
this.lines.splice(row, 0, this.blankLine(undefined, isWrapped));
}
if (this.scrollTop !== 0) {
@@ -2107,8 +2109,9 @@ Terminal.prototype.eraseLine = function(y) {
/**
* Return the data array of a blank line
* @param {number} cur First bunch of data for each "blank" character.
* @param {boolean} isWrapped Whether the new line is wrapped from the previous line.
*/
Terminal.prototype.blankLine = function(cur) {
Terminal.prototype.blankLine = function(cur, isWrapped) {
var attr = cur
? this.eraseAttr()
: this.defAttr;
@@ -2117,6 +2120,12 @@ Terminal.prototype.blankLine = function(cur) {
, line = []
, i = 0;
// TODO: It is not ideal that this is a property on an array, a buffer line
// class should be added that will hold this data and other useful functions.
if (isWrapped) {
line.isWrapped = isWrapped;
}
for (; i < this.cols; i++) {
line[i] = ch;
}