Merge branch 'master' into 1518_memory
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
"jsdoc": "3.4.3",
|
"jsdoc": "3.4.3",
|
||||||
"jsdom": "^11.11.0",
|
"jsdom": "^11.11.0",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^1.0.1",
|
||||||
"node-pty": "^0.7.2",
|
"node-pty": "0.7.6",
|
||||||
"nodemon": "1.10.2",
|
"nodemon": "1.10.2",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"nyc": "^11.8.0",
|
"nyc": "^11.8.0",
|
||||||
|
|||||||
@@ -12,18 +12,22 @@ describe('InputHandler', () => {
|
|||||||
const terminal = new MockInputHandlingTerminal();
|
const terminal = new MockInputHandlingTerminal();
|
||||||
terminal.buffer.x = 1;
|
terminal.buffer.x = 1;
|
||||||
terminal.buffer.y = 2;
|
terminal.buffer.y = 2;
|
||||||
|
terminal.curAttr = 3;
|
||||||
const inputHandler = new InputHandler(terminal);
|
const inputHandler = new InputHandler(terminal);
|
||||||
// Save cursor position
|
// Save cursor position
|
||||||
inputHandler.saveCursor([]);
|
inputHandler.saveCursor([]);
|
||||||
assert.equal(terminal.buffer.x, 1);
|
assert.equal(terminal.buffer.x, 1);
|
||||||
assert.equal(terminal.buffer.y, 2);
|
assert.equal(terminal.buffer.y, 2);
|
||||||
|
assert.equal(terminal.curAttr, 3);
|
||||||
// Change cursor position
|
// Change cursor position
|
||||||
terminal.buffer.x = 10;
|
terminal.buffer.x = 10;
|
||||||
terminal.buffer.y = 20;
|
terminal.buffer.y = 20;
|
||||||
|
terminal.curAttr = 30;
|
||||||
// Restore cursor position
|
// Restore cursor position
|
||||||
inputHandler.restoreCursor([]);
|
inputHandler.restoreCursor([]);
|
||||||
assert.equal(terminal.buffer.x, 1);
|
assert.equal(terminal.buffer.x, 1);
|
||||||
assert.equal(terminal.buffer.y, 2);
|
assert.equal(terminal.buffer.y, 2);
|
||||||
|
assert.equal(terminal.curAttr, 3);
|
||||||
});
|
});
|
||||||
describe('setCursorStyle', () => {
|
describe('setCursorStyle', () => {
|
||||||
it('should call Terminal.setOption with correct params', () => {
|
it('should call Terminal.setOption with correct params', () => {
|
||||||
|
|||||||
@@ -1833,6 +1833,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
public saveCursor(params: number[]): void {
|
public saveCursor(params: number[]): void {
|
||||||
this._terminal.buffer.savedX = this._terminal.buffer.x;
|
this._terminal.buffer.savedX = this._terminal.buffer.x;
|
||||||
this._terminal.buffer.savedY = this._terminal.buffer.y;
|
this._terminal.buffer.savedY = this._terminal.buffer.y;
|
||||||
|
this._terminal.savedCurAttr = this._terminal.curAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1844,6 +1845,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
public restoreCursor(params: number[]): void {
|
public restoreCursor(params: number[]): void {
|
||||||
this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
|
this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
|
||||||
this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
|
this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
|
||||||
|
this._terminal.curAttr = this._terminal.savedCurAttr || DEFAULT_ATTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ if (os.platform() !== 'win32') {
|
|||||||
/** some helpers for pty interaction */
|
/** some helpers for pty interaction */
|
||||||
// we need a pty in between to get the termios decorations
|
// we need a pty in between to get the termios decorations
|
||||||
// for the basic test cases a raw pty device is enough
|
// for the basic test cases a raw pty device is enough
|
||||||
primitivePty = pty.native.open(cols, rows);
|
primitivePty = (<any>pty).native.open(cols, rows);
|
||||||
|
|
||||||
/** tests */
|
/** tests */
|
||||||
describe('xterm output comparison', () => {
|
describe('xterm output comparison', () => {
|
||||||
|
|||||||
@@ -120,6 +120,17 @@ describe('term.js addons', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('reset', () => {
|
||||||
|
it('should not affect cursorState', () => {
|
||||||
|
term.cursorState = 1;
|
||||||
|
term.reset();
|
||||||
|
assert.equal(term.cursorState, 1);
|
||||||
|
term.cursorState = 0;
|
||||||
|
term.reset();
|
||||||
|
assert.equal(term.cursorState, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('clear', () => {
|
describe('clear', () => {
|
||||||
it('should clear a buffer equal to rows', () => {
|
it('should clear a buffer equal to rows', () => {
|
||||||
const promptLine = term.buffer.lines.get(term.buffer.ybase + term.buffer.y);
|
const promptLine = term.buffer.lines.get(term.buffer.ybase + term.buffer.y);
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
public savedCols: number;
|
public savedCols: number;
|
||||||
|
|
||||||
public curAttr: number;
|
public curAttr: number;
|
||||||
|
public savedCurAttr: number;
|
||||||
|
|
||||||
public params: (string | number)[];
|
public params: (string | number)[];
|
||||||
public currentParam: string | number;
|
public currentParam: string | number;
|
||||||
@@ -441,6 +442,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
this.charMeasure.measure(this.options);
|
this.charMeasure.measure(this.options);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'drawBoldTextInBrightColors':
|
||||||
case 'experimentalCharAtlas':
|
case 'experimentalCharAtlas':
|
||||||
case 'enableBold':
|
case 'enableBold':
|
||||||
case 'letterSpacing':
|
case 'letterSpacing':
|
||||||
@@ -1835,9 +1837,11 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
this.options.cols = this.cols;
|
this.options.cols = this.cols;
|
||||||
const customKeyEventHandler = this._customKeyEventHandler;
|
const customKeyEventHandler = this._customKeyEventHandler;
|
||||||
const inputHandler = this._inputHandler;
|
const inputHandler = this._inputHandler;
|
||||||
|
const cursorState = this.cursorState;
|
||||||
this._setup();
|
this._setup();
|
||||||
this._customKeyEventHandler = customKeyEventHandler;
|
this._customKeyEventHandler = customKeyEventHandler;
|
||||||
this._inputHandler = inputHandler;
|
this._inputHandler = inputHandler;
|
||||||
|
this.cursorState = cursorState;
|
||||||
this.refresh(0, this.rows - 1);
|
this.refresh(0, this.rows - 1);
|
||||||
if (this.viewport) {
|
if (this.viewport) {
|
||||||
this.viewport.syncScrollArea();
|
this.viewport.syncScrollArea();
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ export class DomRenderer extends EventEmitter implements IRenderer {
|
|||||||
|
|
||||||
const row = y + terminal.buffer.ydisp;
|
const row = y + terminal.buffer.ydisp;
|
||||||
const lineData = terminal.buffer.lines.get(row);
|
const lineData = terminal.buffer.lines.get(row);
|
||||||
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorX, terminal.charMeasure.width));
|
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorX, terminal.charMeasure.width, terminal.cols));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._terminal.emit('refresh', {start, end});
|
this._terminal.emit('refresh', {start, end});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
describe('createRow', () => {
|
describe('createRow', () => {
|
||||||
it('should create an element for every character in the row', () => {
|
it('should create an element for every character in the row', () => {
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span> </span>' +
|
'<span> </span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -34,24 +34,33 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData[0] = [DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)];
|
lineData[0] = [DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)];
|
||||||
// There should be no element for the following "empty" cell
|
// There should be no element for the following "empty" cell
|
||||||
lineData[1] = [DEFAULT_ATTR, '', 0, undefined];
|
lineData[1] = [DEFAULT_ATTR, '', 0, undefined];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span style="width: 10px;">語</span>'
|
'<span style="width: 10px;">語</span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add class for cursor', () => {
|
it('should add class for cursor', () => {
|
||||||
const fragment = rowFactory.createRow(lineData, true, 0, 5);
|
const fragment = rowFactory.createRow(lineData, true, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-cursor"> </span>' +
|
'<span class="xterm-cursor"> </span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not render cells that go beyond the terminal\'s columns', () => {
|
||||||
|
lineData[0] = [DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)];
|
||||||
|
lineData[1] = [DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)];
|
||||||
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 1);
|
||||||
|
assert.equal(getFragmentHtml(fragment),
|
||||||
|
'<span>a</span>'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
describe('attributes', () => {
|
describe('attributes', () => {
|
||||||
it('should add class for bold', () => {
|
it('should add class for bold', () => {
|
||||||
lineData[0] = [DEFAULT_ATTR | (FLAGS.BOLD << 18), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [DEFAULT_ATTR | (FLAGS.BOLD << 18), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-bold">a</span>' +
|
'<span class="xterm-bold">a</span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -60,7 +69,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
it('should add class for italic', () => {
|
it('should add class for italic', () => {
|
||||||
lineData[0] = [DEFAULT_ATTR | (FLAGS.ITALIC << 18), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [DEFAULT_ATTR | (FLAGS.ITALIC << 18), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-italic">a</span>' +
|
'<span class="xterm-italic">a</span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -71,7 +80,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const defaultAttrNoFgColor = (0 << 9) | (256 << 0);
|
const defaultAttrNoFgColor = (0 << 9) | (256 << 0);
|
||||||
for (let i = 0; i < 256; i++) {
|
for (let i = 0; i < 256; i++) {
|
||||||
lineData[0] = [defaultAttrNoFgColor | (i << 9), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [defaultAttrNoFgColor | (i << 9), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
`<span class="xterm-fg-${i}">a</span>` +
|
`<span class="xterm-fg-${i}">a</span>` +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -83,7 +92,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const defaultAttrNoBgColor = (257 << 9) | (0 << 0);
|
const defaultAttrNoBgColor = (257 << 9) | (0 << 0);
|
||||||
for (let i = 0; i < 256; i++) {
|
for (let i = 0; i < 256; i++) {
|
||||||
lineData[0] = [defaultAttrNoBgColor | (i << 0), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [defaultAttrNoBgColor | (i << 0), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
`<span class="xterm-bg-${i}">a</span>` +
|
`<span class="xterm-bg-${i}">a</span>` +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -93,7 +102,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
it('should correctly invert colors', () => {
|
it('should correctly invert colors', () => {
|
||||||
lineData[0] = [(FLAGS.INVERSE << 18) | (2 << 9) | (1 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [(FLAGS.INVERSE << 18) | (2 << 9) | (1 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-fg-1 xterm-bg-2">a</span>' +
|
'<span class="xterm-fg-1 xterm-bg-2">a</span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -102,7 +111,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
it('should correctly invert default fg color', () => {
|
it('should correctly invert default fg color', () => {
|
||||||
lineData[0] = [(FLAGS.INVERSE << 18) | (257 << 9) | (1 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [(FLAGS.INVERSE << 18) | (257 << 9) | (1 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-fg-1 xterm-bg-15">a</span>' +
|
'<span class="xterm-fg-1 xterm-bg-15">a</span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -111,7 +120,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
it('should correctly invert default bg color', () => {
|
it('should correctly invert default bg color', () => {
|
||||||
lineData[0] = [(FLAGS.INVERSE << 18) | (1 << 9) | (256 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [(FLAGS.INVERSE << 18) | (1 << 9) | (256 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span class="xterm-fg-0 xterm-bg-1">a</span>' +
|
'<span class="xterm-fg-0 xterm-bg-1">a</span>' +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
@@ -121,7 +130,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
it('should turn bold fg text bright', () => {
|
it('should turn bold fg text bright', () => {
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
lineData[0] = [(FLAGS.BOLD << 18) | (i << 9) | (256 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
lineData[0] = [(FLAGS.BOLD << 18) | (i << 9) | (256 << 0), 'a', 1, 'a'.charCodeAt(0)];
|
||||||
const fragment = rowFactory.createRow(lineData, false, 0, 5);
|
const fragment = rowFactory.createRow(lineData, false, 0, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
`<span class="xterm-bold xterm-fg-${i + 8}">a</span>` +
|
`<span class="xterm-bold xterm-fg-${i + 8}">a</span>` +
|
||||||
'<span> </span>'
|
'<span> </span>'
|
||||||
|
|||||||
@@ -17,9 +17,16 @@ export class DomRendererRowFactory {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public createRow(lineData: LineData, isCursorRow: boolean, cursorX: number, cellWidth: number): DocumentFragment {
|
public createRow(lineData: LineData, isCursorRow: boolean, cursorX: number, cellWidth: number, cols: number): DocumentFragment {
|
||||||
const fragment = this._document.createDocumentFragment();
|
const fragment = this._document.createDocumentFragment();
|
||||||
|
let colCount = 0;
|
||||||
|
|
||||||
for (let x = 0; x < lineData.length; x++) {
|
for (let x = 0; x < lineData.length; x++) {
|
||||||
|
// Don't allow any buffer to the right to be displayed
|
||||||
|
if (colCount >= cols) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const charData = lineData[x];
|
const charData = lineData[x];
|
||||||
const char: string = charData[CHAR_DATA_CHAR_INDEX];
|
const char: string = charData[CHAR_DATA_CHAR_INDEX];
|
||||||
const attr: number = charData[CHAR_DATA_ATTR_INDEX];
|
const attr: number = charData[CHAR_DATA_ATTR_INDEX];
|
||||||
@@ -76,6 +83,7 @@ export class DomRendererRowFactory {
|
|||||||
charElement.classList.add(`xterm-bg-${bg}`);
|
charElement.classList.add(`xterm-bg-${bg}`);
|
||||||
}
|
}
|
||||||
fragment.appendChild(charElement);
|
fragment.appendChild(charElement);
|
||||||
|
colCount += width;
|
||||||
}
|
}
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal {
|
|||||||
wraparoundMode: boolean;
|
wraparoundMode: boolean;
|
||||||
bracketedPasteMode: boolean;
|
bracketedPasteMode: boolean;
|
||||||
curAttr: number;
|
curAttr: number;
|
||||||
|
savedCurAttr: number;
|
||||||
savedCols: number;
|
savedCols: number;
|
||||||
x10Mouse: boolean;
|
x10Mouse: boolean;
|
||||||
vt200Mouse: boolean;
|
vt200Mouse: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user