mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #3229 from jerch/replace_expect_testing
replace expect testing with assert
This commit is contained in:
+138
-139
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { assert, expect } from 'chai';
|
||||
import { assert } from 'chai';
|
||||
import { MockViewport, MockCompositionHelper, MockRenderer, TestTerminal } from 'browser/TestUtils.test';
|
||||
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||
import { CellData } from 'common/buffer/CellData';
|
||||
@@ -75,7 +75,7 @@ describe('Terminal', () => {
|
||||
it('should fire a key event after a keypress DOM event', (done) => {
|
||||
term.onKey(e => {
|
||||
assert.equal(typeof e.key, 'string');
|
||||
expect(e.domEvent).to.be.an.instanceof(Object);
|
||||
assert.equal(e.domEvent instanceof Object, true);
|
||||
done();
|
||||
});
|
||||
const evKeyPress = <KeyboardEvent>{
|
||||
@@ -89,7 +89,7 @@ describe('Terminal', () => {
|
||||
it('should fire a key event after a keydown DOM event', (done) => {
|
||||
term.onKey(e => {
|
||||
assert.equal(typeof e.key, 'string');
|
||||
expect(e.domEvent).to.be.an.instanceof(Object);
|
||||
assert.equal(e.domEvent instanceof Object, true);
|
||||
done();
|
||||
});
|
||||
(<any>term).textarea = { value: '' };
|
||||
@@ -103,7 +103,6 @@ describe('Terminal', () => {
|
||||
});
|
||||
it('should fire the onResize event', (done) => {
|
||||
term.onResize(e => {
|
||||
expect(e).to.have.keys(['cols', 'rows']);
|
||||
assert.equal(typeof e.cols, 'number');
|
||||
assert.equal(typeof e.rows, 'number');
|
||||
done();
|
||||
@@ -724,10 +723,10 @@ describe('Terminal', () => {
|
||||
for (let i = 0xDC00; i <= 0xDCFF; ++i) {
|
||||
term.writeSync(high + String.fromCharCode(i));
|
||||
const tchar = term.buffer.lines.get(0)!.loadCell(0, cell);
|
||||
expect(tchar.getChars()).eql(high + String.fromCharCode(i));
|
||||
expect(tchar.getChars().length).eql(2);
|
||||
expect(tchar.getWidth()).eql(1);
|
||||
expect(term.buffer.lines.get(0)!.loadCell(1, cell).getChars()).eql('');
|
||||
assert.equal(tchar.getChars(), high + String.fromCharCode(i));
|
||||
assert.equal(tchar.getChars().length, 2);
|
||||
assert.equal(tchar.getWidth(), 1);
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), '');
|
||||
term.reset();
|
||||
}
|
||||
});
|
||||
@@ -737,9 +736,9 @@ describe('Terminal', () => {
|
||||
for (let i = 0xDC00; i <= 0xDCFF; ++i) {
|
||||
term.buffer.x = term.cols - 1;
|
||||
term.writeSync(high + String.fromCharCode(i));
|
||||
expect(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars()).eql(high + String.fromCharCode(i));
|
||||
expect(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length).eql(2);
|
||||
expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars()).eql('');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i));
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2);
|
||||
assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), '');
|
||||
term.reset();
|
||||
}
|
||||
});
|
||||
@@ -750,10 +749,10 @@ describe('Terminal', () => {
|
||||
term.buffer.x = term.cols - 1;
|
||||
|
||||
term.writeSync('a' + high + String.fromCharCode(i));
|
||||
expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars()).eql('a');
|
||||
expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars()).eql(high + String.fromCharCode(i));
|
||||
expect(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length).eql(2);
|
||||
expect(term.buffer.lines.get(1)!.loadCell(1, cell).getChars()).eql('');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a');
|
||||
assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i));
|
||||
assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2);
|
||||
assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), '');
|
||||
term.reset();
|
||||
}
|
||||
});
|
||||
@@ -769,9 +768,9 @@ describe('Terminal', () => {
|
||||
}
|
||||
term.writeSync('a' + high + String.fromCharCode(i));
|
||||
// auto wraparound mode should cut off the rest of the line
|
||||
expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars()).eql(high + String.fromCharCode(i));
|
||||
expect(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length).eql(2);
|
||||
expect(term.buffer.lines.get(1)!.loadCell(1, cell).getChars()).eql('');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i));
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2);
|
||||
assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), '');
|
||||
term.reset();
|
||||
}
|
||||
});
|
||||
@@ -782,10 +781,10 @@ describe('Terminal', () => {
|
||||
term.writeSync(high);
|
||||
term.writeSync(String.fromCharCode(i));
|
||||
const tchar = term.buffer.lines.get(0)!.loadCell(0, cell);
|
||||
expect(tchar.getChars()).eql(high + String.fromCharCode(i));
|
||||
expect(tchar.getChars().length).eql(2);
|
||||
expect(tchar.getWidth()).eql(1);
|
||||
expect(term.buffer.lines.get(0)!.loadCell(1, cell).getChars()).eql('');
|
||||
assert.equal(tchar.getChars(), high + String.fromCharCode(i));
|
||||
assert.equal(tchar.getChars().length, 2);
|
||||
assert.equal(tchar.getWidth(), 1);
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), '');
|
||||
term.reset();
|
||||
}
|
||||
});
|
||||
@@ -796,81 +795,81 @@ describe('Terminal', () => {
|
||||
it('café', () => {
|
||||
term.writeSync('cafe\u0301');
|
||||
term.buffer.lines.get(0)!.loadCell(3, cell);
|
||||
expect(cell.getChars()).eql('e\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), 'e\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
});
|
||||
it('café - end of line', () => {
|
||||
term.buffer.x = term.cols - 1 - 3;
|
||||
term.writeSync('cafe\u0301');
|
||||
term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell);
|
||||
expect(cell.getChars()).eql('e\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), 'e\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
term.buffer.lines.get(0)!.loadCell(1, cell);
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
});
|
||||
it('multiple combined é', () => {
|
||||
term.writeSync(Array(100).join('e\u0301'));
|
||||
for (let i = 0; i < term.cols; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
expect(cell.getChars()).eql('e\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), 'e\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
}
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('e\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), 'e\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
});
|
||||
it('multiple surrogate with combined', () => {
|
||||
term.writeSync(Array(100).join('\uD800\uDC00\u0301'));
|
||||
for (let i = 0; i < term.cols; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
expect(cell.getChars()).eql('\uD800\uDC00\u0301');
|
||||
expect(cell.getChars().length).eql(3);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), '\uD800\uDC00\u0301');
|
||||
assert.equal(cell.getChars().length, 3);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
}
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('\uD800\uDC00\u0301');
|
||||
expect(cell.getChars().length).eql(3);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), '\uD800\uDC00\u0301');
|
||||
assert.equal(cell.getChars().length, 3);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unicode - fullwidth characters', () => {
|
||||
const cell = new CellData();
|
||||
it('cursor movement even', () => {
|
||||
expect(term.buffer.x).eql(0);
|
||||
assert.equal(term.buffer.x, 0);
|
||||
term.writeSync('¥');
|
||||
expect(term.buffer.x).eql(2);
|
||||
assert.equal(term.buffer.x, 2);
|
||||
});
|
||||
it('cursor movement odd', () => {
|
||||
term.buffer.x = 1;
|
||||
expect(term.buffer.x).eql(1);
|
||||
assert.equal(term.buffer.x, 1);
|
||||
term.writeSync('¥');
|
||||
expect(term.buffer.x).eql(3);
|
||||
assert.equal(term.buffer.x, 3);
|
||||
});
|
||||
it('line of ¥ even', () => {
|
||||
term.writeSync(Array(50).join('¥'));
|
||||
for (let i = 0; i < term.cols; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
if (i % 2) {
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(0);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 0);
|
||||
} else {
|
||||
expect(cell.getChars()).eql('¥');
|
||||
expect(cell.getChars().length).eql(1);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥');
|
||||
assert.equal(cell.getChars().length, 1);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
}
|
||||
}
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('¥');
|
||||
expect(cell.getChars().length).eql(1);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥');
|
||||
assert.equal(cell.getChars().length, 1);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
});
|
||||
it('line of ¥ odd', () => {
|
||||
term.buffer.x = 1;
|
||||
@@ -878,23 +877,23 @@ describe('Terminal', () => {
|
||||
for (let i = 1; i < term.cols - 1; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
if (!(i % 2)) {
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(0);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 0);
|
||||
} else {
|
||||
expect(cell.getChars()).eql('¥');
|
||||
expect(cell.getChars().length).eql(1);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥');
|
||||
assert.equal(cell.getChars().length, 1);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
}
|
||||
}
|
||||
term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell);
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('¥');
|
||||
expect(cell.getChars().length).eql(1);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥');
|
||||
assert.equal(cell.getChars().length, 1);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
});
|
||||
it('line of ¥ with combining odd', () => {
|
||||
term.buffer.x = 1;
|
||||
@@ -902,42 +901,42 @@ describe('Terminal', () => {
|
||||
for (let i = 1; i < term.cols - 1; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
if (!(i % 2)) {
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(0);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 0);
|
||||
} else {
|
||||
expect(cell.getChars()).eql('¥\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
}
|
||||
}
|
||||
term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell);
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('¥\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
});
|
||||
it('line of ¥ with combining even', () => {
|
||||
term.writeSync(Array(50).join('¥\u0301'));
|
||||
for (let i = 0; i < term.cols; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
if (i % 2) {
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(0);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 0);
|
||||
} else {
|
||||
expect(cell.getChars()).eql('¥\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
}
|
||||
}
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('¥\u0301');
|
||||
expect(cell.getChars().length).eql(2);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '¥\u0301');
|
||||
assert.equal(cell.getChars().length, 2);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
});
|
||||
it('line of surrogate fullwidth with combining odd', () => {
|
||||
term.buffer.x = 1;
|
||||
@@ -945,42 +944,42 @@ describe('Terminal', () => {
|
||||
for (let i = 1; i < term.cols - 1; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
if (!(i % 2)) {
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(0);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 0);
|
||||
} else {
|
||||
expect(cell.getChars()).eql('\ud843\ude6d\u0301');
|
||||
expect(cell.getChars().length).eql(3);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '\ud843\ude6d\u0301');
|
||||
assert.equal(cell.getChars().length, 3);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
}
|
||||
}
|
||||
term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell);
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(1);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 1);
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('\ud843\ude6d\u0301');
|
||||
expect(cell.getChars().length).eql(3);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '\ud843\ude6d\u0301');
|
||||
assert.equal(cell.getChars().length, 3);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
});
|
||||
it('line of surrogate fullwidth with combining even', () => {
|
||||
term.writeSync(Array(50).join('\ud843\ude6d\u0301'));
|
||||
for (let i = 0; i < term.cols; ++i) {
|
||||
term.buffer.lines.get(0)!.loadCell(i, cell);
|
||||
if (i % 2) {
|
||||
expect(cell.getChars()).eql('');
|
||||
expect(cell.getChars().length).eql(0);
|
||||
expect(cell.getWidth()).eql(0);
|
||||
assert.equal(cell.getChars(), '');
|
||||
assert.equal(cell.getChars().length, 0);
|
||||
assert.equal(cell.getWidth(), 0);
|
||||
} else {
|
||||
expect(cell.getChars()).eql('\ud843\ude6d\u0301');
|
||||
expect(cell.getChars().length).eql(3);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '\ud843\ude6d\u0301');
|
||||
assert.equal(cell.getChars().length, 3);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
}
|
||||
}
|
||||
term.buffer.lines.get(1)!.loadCell(0, cell);
|
||||
expect(cell.getChars()).eql('\ud843\ude6d\u0301');
|
||||
expect(cell.getChars().length).eql(3);
|
||||
expect(cell.getWidth()).eql(2);
|
||||
assert.equal(cell.getChars(), '\ud843\ude6d\u0301');
|
||||
assert.equal(cell.getChars().length, 3);
|
||||
assert.equal(cell.getWidth(), 2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -992,11 +991,11 @@ describe('Terminal', () => {
|
||||
term.buffer.y = 0;
|
||||
term.write('\x1b[4h');
|
||||
term.writeSync('abcde');
|
||||
expect(term.buffer.lines.get(0)!.length).eql(term.cols);
|
||||
expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('a');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(14, cell).getChars()).eql('e');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(15, cell).getChars()).eql('0');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql('4');
|
||||
assert.equal(term.buffer.lines.get(0)!.length, term.cols);
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), 'e');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '0');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '4');
|
||||
});
|
||||
it('fullwidth - insert', () => {
|
||||
term.writeSync(Array(9).join('0123456789').slice(-80));
|
||||
@@ -1004,12 +1003,12 @@ describe('Terminal', () => {
|
||||
term.buffer.y = 0;
|
||||
term.write('\x1b[4h');
|
||||
term.writeSync('¥¥¥');
|
||||
expect(term.buffer.lines.get(0)!.length).eql(term.cols);
|
||||
expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('¥');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(14, cell).getChars()).eql('¥');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(15, cell).getChars()).eql('');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql('3');
|
||||
assert.equal(term.buffer.lines.get(0)!.length, term.cols);
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), '¥');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(14, cell).getChars(), '¥');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(15, cell).getChars(), '');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), '3');
|
||||
});
|
||||
it('fullwidth - right border', () => {
|
||||
term.writeSync(Array(41).join('¥'));
|
||||
@@ -1017,15 +1016,15 @@ describe('Terminal', () => {
|
||||
term.buffer.y = 0;
|
||||
term.write('\x1b[4h');
|
||||
term.writeSync('a');
|
||||
expect(term.buffer.lines.get(0)!.length).eql(term.cols);
|
||||
expect(term.buffer.lines.get(0)!.loadCell(10, cell).getChars()).eql('a');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('¥');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql(''); // fullwidth char got replaced
|
||||
assert.equal(term.buffer.lines.get(0)!.length, term.cols);
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(10, cell).getChars(), 'a');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), '¥');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // fullwidth char got replaced
|
||||
term.writeSync('b');
|
||||
expect(term.buffer.lines.get(0)!.length).eql(term.cols);
|
||||
expect(term.buffer.lines.get(0)!.loadCell(11, cell).getChars()).eql('b');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(12, cell).getChars()).eql('¥');
|
||||
expect(term.buffer.lines.get(0)!.loadCell(79, cell).getChars()).eql(''); // empty cell after fullwidth
|
||||
assert.equal(term.buffer.lines.get(0)!.length, term.cols);
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(11, cell).getChars(), 'b');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(12, cell).getChars(), '¥');
|
||||
assert.equal(term.buffer.lines.get(0)!.loadCell(79, cell).getChars(), ''); // empty cell after fullwidth
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1346,7 +1345,7 @@ describe('Terminal', () => {
|
||||
];
|
||||
terminal.writeSync(data.join(''));
|
||||
// brute force test with insane values
|
||||
expect(() => {
|
||||
assert.doesNotThrow(() => {
|
||||
for (let overscan = 0; overscan < 20; ++overscan) {
|
||||
for (let start = -10; start < 20; ++start) {
|
||||
for (let end = -10; end < 20; ++end) {
|
||||
@@ -1357,7 +1356,7 @@ describe('Terminal', () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).to.not.throw();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1406,18 +1405,18 @@ describe('Terminal', () => {
|
||||
// not converting
|
||||
const termNotConverting = new TestTerminal({cols: 15, rows: 10});
|
||||
termNotConverting.writeSync('Hello\nWorld');
|
||||
expect(termNotConverting.buffer.lines.get(0)!.translateToString(false)).equals('Hello ');
|
||||
expect(termNotConverting.buffer.lines.get(1)!.translateToString(false)).equals(' World ');
|
||||
expect(termNotConverting.buffer.lines.get(0)!.translateToString(true)).equals('Hello');
|
||||
expect(termNotConverting.buffer.lines.get(1)!.translateToString(true)).equals(' World');
|
||||
assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(false), 'Hello ');
|
||||
assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(false), ' World ');
|
||||
assert.equal(termNotConverting.buffer.lines.get(0)!.translateToString(true), 'Hello');
|
||||
assert.equal(termNotConverting.buffer.lines.get(1)!.translateToString(true), ' World');
|
||||
|
||||
// converting
|
||||
const termConverting = new TestTerminal({cols: 15, rows: 10, convertEol: true});
|
||||
termConverting.writeSync('Hello\nWorld');
|
||||
expect(termConverting.buffer.lines.get(0)!.translateToString(false)).equals('Hello ');
|
||||
expect(termConverting.buffer.lines.get(1)!.translateToString(false)).equals('World ');
|
||||
expect(termConverting.buffer.lines.get(0)!.translateToString(true)).equals('Hello');
|
||||
expect(termConverting.buffer.lines.get(1)!.translateToString(true)).equals('World');
|
||||
assert.equal(termConverting.buffer.lines.get(0)!.translateToString(false), 'Hello ');
|
||||
assert.equal(termConverting.buffer.lines.get(1)!.translateToString(false), 'World ');
|
||||
assert.equal(termConverting.buffer.lines.get(0)!.translateToString(true), 'Hello');
|
||||
assert.equal(termConverting.buffer.lines.get(1)!.translateToString(true), 'World');
|
||||
});
|
||||
describe('Terminal InputHandler integration', () => {
|
||||
function getLines(term: TestTerminal, limit: number = term.rows): string[] {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { assert, expect } from 'chai';
|
||||
import { assert } from 'chai';
|
||||
import { clone } from 'common/Clone';
|
||||
|
||||
describe('clone', () => {
|
||||
@@ -124,6 +124,6 @@ describe('clone', () => {
|
||||
|
||||
test.a.b.c = test;
|
||||
|
||||
expect(() => clone(test)).to.not.throw();
|
||||
assert.doesNotThrow(() => clone(test));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { assert, expect } from 'chai';
|
||||
import { assert } from 'chai';
|
||||
import { InputHandler } from 'common/InputHandler';
|
||||
import { IBufferLine, IAttributeData, IAnsiColorChangeEvent } from 'common/Types';
|
||||
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||
@@ -136,7 +136,16 @@ describe('InputHandler', () => {
|
||||
|
||||
it('insertChars', function(): void {
|
||||
const bufferService = new MockBufferService(80, 30);
|
||||
const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||
const inputHandler = new TestInputHandler(
|
||||
bufferService,
|
||||
new MockCharsetService(),
|
||||
new MockCoreService(),
|
||||
new MockDirtyRowService(),
|
||||
new MockLogService(),
|
||||
new MockOptionsService(),
|
||||
new MockCoreMouseService(),
|
||||
new MockUnicodeService()
|
||||
);
|
||||
|
||||
// insert some data in first and second line
|
||||
inputHandler.parse(Array(bufferService.cols - 9).join('a'));
|
||||
@@ -144,36 +153,45 @@ describe('InputHandler', () => {
|
||||
inputHandler.parse(Array(bufferService.cols - 9).join('a'));
|
||||
inputHandler.parse('1234567890');
|
||||
const line1: IBufferLine = bufferService.buffer.lines.get(0)!;
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '1234567890');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '1234567890');
|
||||
|
||||
// insert one char from params = [0]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.insertChars(Params.fromArray([0]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' 123456789');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' 123456789');
|
||||
|
||||
// insert one char from params = [1]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.insertChars(Params.fromArray([1]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' 12345678');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' 12345678');
|
||||
|
||||
// insert two chars from params = [2]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.insertChars(Params.fromArray([2]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' 123456');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' 123456');
|
||||
|
||||
// insert 10 chars from params = [10]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.insertChars(Params.fromArray([10]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' ');
|
||||
expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a'));
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' ');
|
||||
assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a'));
|
||||
});
|
||||
it('deleteChars', function(): void {
|
||||
const bufferService = new MockBufferService(80, 30);
|
||||
const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||
const inputHandler = new TestInputHandler(
|
||||
bufferService,
|
||||
new MockCharsetService(),
|
||||
new MockCoreService(),
|
||||
new MockDirtyRowService(),
|
||||
new MockLogService(),
|
||||
new MockOptionsService(),
|
||||
new MockCoreMouseService(),
|
||||
new MockUnicodeService()
|
||||
);
|
||||
|
||||
// insert some data in first and second line
|
||||
inputHandler.parse(Array(bufferService.cols - 9).join('a'));
|
||||
@@ -181,39 +199,49 @@ describe('InputHandler', () => {
|
||||
inputHandler.parse(Array(bufferService.cols - 9).join('a'));
|
||||
inputHandler.parse('1234567890');
|
||||
const line1: IBufferLine = bufferService.buffer.lines.get(0)!;
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '1234567890');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '1234567890');
|
||||
|
||||
// delete one char from params = [0]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.deleteChars(Params.fromArray([0]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '234567890 ');
|
||||
expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a') + '234567890');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '234567890 ');
|
||||
assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a') + '234567890');
|
||||
|
||||
// insert one char from params = [1]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.deleteChars(Params.fromArray([1]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '34567890 ');
|
||||
expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a') + '34567890');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '34567890 ');
|
||||
assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a') + '34567890');
|
||||
|
||||
// insert two chars from params = [2]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.deleteChars(Params.fromArray([2]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + '567890 ');
|
||||
expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a') + '567890');
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + '567890 ');
|
||||
assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a') + '567890');
|
||||
|
||||
|
||||
// insert 10 chars from params = [10]
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.deleteChars(Params.fromArray([10]));
|
||||
expect(line1.translateToString(false)).equals(Array(bufferService.cols - 9).join('a') + ' ');
|
||||
expect(line1.translateToString(true)).equals(Array(bufferService.cols - 9).join('a'));
|
||||
assert.equal(line1.translateToString(false), Array(bufferService.cols - 9).join('a') + ' ');
|
||||
assert.equal(line1.translateToString(true), Array(bufferService.cols - 9).join('a'));
|
||||
});
|
||||
it('eraseInLine', function(): void {
|
||||
const bufferService = new MockBufferService(80, 30);
|
||||
const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||
const inputHandler = new TestInputHandler(
|
||||
bufferService,
|
||||
new MockCharsetService(),
|
||||
new MockCoreService(),
|
||||
new MockDirtyRowService(),
|
||||
new MockLogService(),
|
||||
new MockOptionsService(),
|
||||
new MockCoreMouseService(),
|
||||
new MockUnicodeService()
|
||||
);
|
||||
|
||||
// fill 6 lines to test 3 different states
|
||||
inputHandler.parse(Array(bufferService.cols + 1).join('a'));
|
||||
@@ -224,24 +252,33 @@ describe('InputHandler', () => {
|
||||
bufferService.buffer.y = 0;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.eraseInLine(Params.fromArray([0]));
|
||||
expect(bufferService.buffer.lines.get(0)!.translateToString(false)).equals(Array(71).join('a') + ' ');
|
||||
assert.equal(bufferService.buffer.lines.get(0)!.translateToString(false), Array(71).join('a') + ' ');
|
||||
|
||||
// params[1] - left erase
|
||||
bufferService.buffer.y = 1;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.eraseInLine(Params.fromArray([1]));
|
||||
expect(bufferService.buffer.lines.get(1)!.translateToString(false)).equals(Array(71).join(' ') + ' aaaaaaaaa');
|
||||
assert.equal(bufferService.buffer.lines.get(1)!.translateToString(false), Array(71).join(' ') + ' aaaaaaaaa');
|
||||
|
||||
// params[1] - left erase
|
||||
bufferService.buffer.y = 2;
|
||||
bufferService.buffer.x = 70;
|
||||
inputHandler.eraseInLine(Params.fromArray([2]));
|
||||
expect(bufferService.buffer.lines.get(2)!.translateToString(false)).equals(Array(bufferService.cols + 1).join(' '));
|
||||
assert.equal(bufferService.buffer.lines.get(2)!.translateToString(false), Array(bufferService.cols + 1).join(' '));
|
||||
|
||||
});
|
||||
it('eraseInDisplay', function(): void {
|
||||
const bufferService = new MockBufferService(80, 7);
|
||||
const inputHandler = new InputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||
const inputHandler = new TestInputHandler(
|
||||
bufferService,
|
||||
new MockCharsetService(),
|
||||
new MockCoreService(),
|
||||
new MockDirtyRowService(),
|
||||
new MockLogService(),
|
||||
new MockOptionsService(),
|
||||
new MockCoreMouseService(),
|
||||
new MockUnicodeService()
|
||||
);
|
||||
|
||||
// fill display with a's
|
||||
for (let i = 0; i < bufferService.rows; ++i) inputHandler.parse(Array(bufferService.cols + 1).join('a'));
|
||||
@@ -250,7 +287,7 @@ describe('InputHandler', () => {
|
||||
bufferService.buffer.y = 5;
|
||||
bufferService.buffer.x = 40;
|
||||
inputHandler.eraseInDisplay(Params.fromArray([0]));
|
||||
expect(termContent(bufferService, false)).eql([
|
||||
assert.deepEqual(termContent(bufferService, false), [
|
||||
Array(bufferService.cols + 1).join('a'),
|
||||
Array(bufferService.cols + 1).join('a'),
|
||||
Array(bufferService.cols + 1).join('a'),
|
||||
@@ -259,7 +296,7 @@ describe('InputHandler', () => {
|
||||
Array(40 + 1).join('a') + Array(bufferService.cols - 40 + 1).join(' '),
|
||||
Array(bufferService.cols + 1).join(' ')
|
||||
]);
|
||||
expect(termContent(bufferService, true)).eql([
|
||||
assert.deepEqual(termContent(bufferService, true), [
|
||||
Array(bufferService.cols + 1).join('a'),
|
||||
Array(bufferService.cols + 1).join('a'),
|
||||
Array(bufferService.cols + 1).join('a'),
|
||||
@@ -278,7 +315,7 @@ describe('InputHandler', () => {
|
||||
bufferService.buffer.y = 5;
|
||||
bufferService.buffer.x = 40;
|
||||
inputHandler.eraseInDisplay(Params.fromArray([1]));
|
||||
expect(termContent(bufferService, false)).eql([
|
||||
assert.deepEqual(termContent(bufferService, false), [
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
@@ -287,7 +324,7 @@ describe('InputHandler', () => {
|
||||
Array(41 + 1).join(' ') + Array(bufferService.cols - 41 + 1).join('a'),
|
||||
Array(bufferService.cols + 1).join('a')
|
||||
]);
|
||||
expect(termContent(bufferService, true)).eql([
|
||||
assert.deepEqual(termContent(bufferService, true), [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
@@ -306,7 +343,7 @@ describe('InputHandler', () => {
|
||||
bufferService.buffer.y = 5;
|
||||
bufferService.buffer.x = 40;
|
||||
inputHandler.eraseInDisplay(Params.fromArray([2]));
|
||||
expect(termContent(bufferService, false)).eql([
|
||||
assert.deepEqual(termContent(bufferService, false), [
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
@@ -315,7 +352,7 @@ describe('InputHandler', () => {
|
||||
Array(bufferService.cols + 1).join(' '),
|
||||
Array(bufferService.cols + 1).join(' ')
|
||||
]);
|
||||
expect(termContent(bufferService, true)).eql([
|
||||
assert.deepEqual(termContent(bufferService, true), [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
@@ -334,11 +371,11 @@ describe('InputHandler', () => {
|
||||
|
||||
// params[1] left and above with wrap
|
||||
// confirm precondition that line 2 is wrapped
|
||||
expect(bufferService.buffer.lines.get(2)!.isWrapped).true;
|
||||
assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, true);
|
||||
bufferService.buffer.y = 2;
|
||||
bufferService.buffer.x = 40;
|
||||
inputHandler.eraseInDisplay(Params.fromArray([1]));
|
||||
expect(bufferService.buffer.lines.get(2)!.isWrapped).false;
|
||||
assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, false);
|
||||
|
||||
// reset and add a wrapped line
|
||||
bufferService.buffer.y = 0;
|
||||
@@ -349,16 +386,25 @@ describe('InputHandler', () => {
|
||||
|
||||
// params[1] left and above with wrap
|
||||
// confirm precondition that line 2 is wrapped
|
||||
expect(bufferService.buffer.lines.get(2)!.isWrapped).true;
|
||||
assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, true);
|
||||
bufferService.buffer.y = 1;
|
||||
bufferService.buffer.x = 90; // Cursor is beyond last column
|
||||
inputHandler.eraseInDisplay(Params.fromArray([1]));
|
||||
expect(bufferService.buffer.lines.get(2)!.isWrapped).false;
|
||||
assert.equal(bufferService.buffer.lines.get(2)!.isWrapped, false);
|
||||
});
|
||||
});
|
||||
describe('print', () => {
|
||||
it('should not cause an infinite loop (regression test)', () => {
|
||||
const inputHandler = new InputHandler(new MockBufferService(80, 30), new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||
const inputHandler = new TestInputHandler(
|
||||
new MockBufferService(80, 30),
|
||||
new MockCharsetService(),
|
||||
new MockCoreService(),
|
||||
new MockDirtyRowService(),
|
||||
new MockLogService(),
|
||||
new MockOptionsService(),
|
||||
new MockCoreMouseService(),
|
||||
new MockUnicodeService()
|
||||
);
|
||||
const container = new Uint32Array(10);
|
||||
container[0] = 0x200B;
|
||||
inputHandler.print(container, 0, 1);
|
||||
@@ -383,48 +429,48 @@ describe('InputHandler', () => {
|
||||
});
|
||||
it('should handle DECSET/DECRST 47 (alt screen buffer)', () => {
|
||||
handler.parse('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('');
|
||||
expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(' TEST');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(0, true), '');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(1, true), ' TEST');
|
||||
// Text color of 'TEST' should be red
|
||||
expect((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor())).to.equal(1);
|
||||
assert.equal((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor()), 1);
|
||||
});
|
||||
it('should handle DECSET/DECRST 1047 (alt screen buffer)', () => {
|
||||
handler.parse('\x1b[?1047h\r\n\x1b[31mJUNK\x1b[?1047lTEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('');
|
||||
expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal(' TEST');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(0, true), '');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(1, true), ' TEST');
|
||||
// Text color of 'TEST' should be red
|
||||
expect((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor())).to.equal(1);
|
||||
assert.equal((bufferService.buffer.lines.get(1)!.loadCell(4, new CellData()).getFgColor()), 1);
|
||||
});
|
||||
it('should handle DECSET/DECRST 1048 (alt screen cursor)', () => {
|
||||
handler.parse('\x1b[?1048h\r\n\x1b[31mJUNK\x1b[?1048lTEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('JUNK');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(0, true), 'TEST');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(1, true), 'JUNK');
|
||||
// Text color of 'TEST' should be default
|
||||
expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg);
|
||||
assert.equal(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg, DEFAULT_ATTR_DATA.fg);
|
||||
// Text color of 'JUNK' should be red
|
||||
expect((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor())).to.equal(1);
|
||||
assert.equal((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor()), 1);
|
||||
});
|
||||
it('should handle DECSET/DECRST 1049 (alt screen buffer+cursor)', () => {
|
||||
handler.parse('\x1b[?1049h\r\n\x1b[31mJUNK\x1b[?1049lTEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(0, true), 'TEST');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(1, true), '');
|
||||
// Text color of 'TEST' should be default
|
||||
expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg);
|
||||
assert.equal(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg, DEFAULT_ATTR_DATA.fg);
|
||||
});
|
||||
it('should handle DECSET/DECRST 1049 - maintains saved cursor for alt buffer', () => {
|
||||
handler.parse('\x1b[?1049h\r\n\x1b[31m\x1b[s\x1b[?1049lTEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(0, true)).to.equal('TEST');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(0, true), 'TEST');
|
||||
// Text color of 'TEST' should be default
|
||||
expect(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg);
|
||||
assert.equal(bufferService.buffer.lines.get(0)!.loadCell(0, new CellData()).fg, DEFAULT_ATTR_DATA.fg);
|
||||
handler.parse('\x1b[?1049h\x1b[uTEST');
|
||||
expect(bufferService.buffer.translateBufferLineToString(1, true)).to.equal('TEST');
|
||||
assert.equal(bufferService.buffer.translateBufferLineToString(1, true), 'TEST');
|
||||
// Text color of 'TEST' should be red
|
||||
expect((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor())).to.equal(1);
|
||||
assert.equal((bufferService.buffer.lines.get(1)!.loadCell(0, new CellData()).getFgColor()), 1);
|
||||
});
|
||||
it('should handle DECSET/DECRST 1049 - clears alt buffer with erase attributes', () => {
|
||||
handler.parse('\x1b[42m\x1b[?1049h');
|
||||
// Buffer should be filled with green background
|
||||
expect(bufferService.buffer.lines.get(20)!.loadCell(10, new CellData()).getBgColor()).to.equal(2);
|
||||
assert.equal(bufferService.buffer.lines.get(20)!.loadCell(10, new CellData()).getBgColor(), 2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR, Content,
|
||||
import { BufferLine } from 'common/buffer//BufferLine';
|
||||
import { CellData } from 'common/buffer/CellData';
|
||||
import { CharData, IBufferLine } from '../Types';
|
||||
import { assert, expect } from 'chai';
|
||||
import { assert } from 'chai';
|
||||
import { AttributeData } from 'common/buffer/AttributeData';
|
||||
|
||||
|
||||
@@ -151,20 +151,20 @@ describe('CellData', () => {
|
||||
describe('BufferLine', function(): void {
|
||||
it('ctor', function(): void {
|
||||
let line: IBufferLine = new TestBufferLine(0);
|
||||
expect(line.length).equals(0);
|
||||
expect(line.isWrapped).equals(false);
|
||||
assert.equal(line.length, 0);
|
||||
assert.equal(line.isWrapped, false);
|
||||
line = new TestBufferLine(10);
|
||||
expect(line.length).equals(10);
|
||||
expect(line.loadCell(0, new CellData()).getAsCharData()).eql([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
expect(line.isWrapped).equals(false);
|
||||
assert.equal(line.length, 10);
|
||||
assert.deepEqual(line.loadCell(0, new CellData()).getAsCharData(), [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
assert.equal(line.isWrapped, false);
|
||||
line = new TestBufferLine(10, undefined, true);
|
||||
expect(line.length).equals(10);
|
||||
expect(line.loadCell(0, new CellData()).getAsCharData()).eql([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
expect(line.isWrapped).equals(true);
|
||||
assert.equal(line.length, 10);
|
||||
assert.deepEqual(line.loadCell(0, new CellData()).getAsCharData(), [0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
|
||||
assert.equal(line.isWrapped, true);
|
||||
line = new TestBufferLine(10, CellData.fromCharData([123, 'a', 456, 'a'.charCodeAt(0)]), true);
|
||||
expect(line.length).equals(10);
|
||||
expect(line.loadCell(0, new CellData()).getAsCharData()).eql([123, 'a', 456, 'a'.charCodeAt(0)]);
|
||||
expect(line.isWrapped).equals(true);
|
||||
assert.equal(line.length, 10);
|
||||
assert.deepEqual(line.loadCell(0, new CellData()).getAsCharData(), [123, 'a', 456, 'a'.charCodeAt(0)]);
|
||||
assert.equal(line.isWrapped, true);
|
||||
});
|
||||
it('insertCells', function(): void {
|
||||
const line = new TestBufferLine(3);
|
||||
@@ -172,7 +172,7 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(1, CellData.fromCharData([2, 'b', 0, 'b'.charCodeAt(0)]));
|
||||
line.setCell(2, CellData.fromCharData([3, 'c', 0, 'c'.charCodeAt(0)]));
|
||||
line.insertCells(1, 3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql([
|
||||
assert.deepEqual(line.toArray(), [
|
||||
[1, 'a', 0, 'a'.charCodeAt(0)],
|
||||
[4, 'd', 0, 'd'.charCodeAt(0)],
|
||||
[4, 'd', 0, 'd'.charCodeAt(0)]
|
||||
@@ -186,7 +186,7 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)]));
|
||||
line.deleteCells(1, 2, CellData.fromCharData([6, 'f', 0, 'f'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql([
|
||||
assert.deepEqual(line.toArray(), [
|
||||
[1, 'a', 0, 'a'.charCodeAt(0)],
|
||||
[4, 'd', 0, 'd'.charCodeAt(0)],
|
||||
[5, 'e', 0, 'e'.charCodeAt(0)],
|
||||
@@ -202,7 +202,7 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)]));
|
||||
line.replaceCells(2, 4, CellData.fromCharData([6, 'f', 0, 'f'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql([
|
||||
assert.deepEqual(line.toArray(), [
|
||||
[1, 'a', 0, 'a'.charCodeAt(0)],
|
||||
[2, 'b', 0, 'b'.charCodeAt(0)],
|
||||
[6, 'f', 0, 'f'.charCodeAt(0)],
|
||||
@@ -218,7 +218,7 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)]));
|
||||
line.fill(CellData.fromCharData([123, 'z', 0, 'z'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql([
|
||||
assert.deepEqual(line.toArray(), [
|
||||
[123, 'z', 0, 'z'.charCodeAt(0)],
|
||||
[123, 'z', 0, 'z'.charCodeAt(0)],
|
||||
[123, 'z', 0, 'z'.charCodeAt(0)],
|
||||
@@ -234,9 +234,9 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(3, CellData.fromCharData([4, 'd', 0, 'd'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)]));
|
||||
const line2 = line.clone();
|
||||
expect(TestBufferLine.prototype.toArray.apply(line2)).eql(line.toArray());
|
||||
expect(line2.length).equals(line.length);
|
||||
expect(line2.isWrapped).equals(line.isWrapped);
|
||||
assert.deepEqual(TestBufferLine.prototype.toArray.apply(line2), line.toArray());
|
||||
assert.equal(line2.length, line.length);
|
||||
assert.equal(line2.isWrapped, line.isWrapped);
|
||||
});
|
||||
it('copyFrom', function(): void {
|
||||
const line = new TestBufferLine(5);
|
||||
@@ -247,92 +247,92 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(4, CellData.fromCharData([5, 'e', 0, 'e'.charCodeAt(0)]));
|
||||
const line2 = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), true);
|
||||
line2.copyFrom(line);
|
||||
expect(line2.toArray()).eql(line.toArray());
|
||||
expect(line2.length).equals(line.length);
|
||||
expect(line2.isWrapped).equals(line.isWrapped);
|
||||
assert.deepEqual(line2.toArray(), line.toArray());
|
||||
assert.equal(line2.length, line.length);
|
||||
assert.equal(line2.isWrapped, line.isWrapped);
|
||||
});
|
||||
it('should support combining chars', function(): void {
|
||||
// CHAR_DATA_CODE_INDEX resembles current behavior in InputHandler.print
|
||||
// --> set code to the last charCodeAt value of the string
|
||||
// Note: needs to be fixed once the string pointer is in place
|
||||
const line = new TestBufferLine(2, CellData.fromCharData([1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql([[1, 'e\u0301', 0, '\u0301'.charCodeAt(0)], [1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]]);
|
||||
assert.deepEqual(line.toArray(), [[1, 'e\u0301', 0, '\u0301'.charCodeAt(0)], [1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]]);
|
||||
const line2 = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, '\u0301'.charCodeAt(0)]), true);
|
||||
line2.copyFrom(line);
|
||||
expect(line2.toArray()).eql(line.toArray());
|
||||
assert.deepEqual(line2.toArray(), line.toArray());
|
||||
const line3 = line.clone();
|
||||
expect(TestBufferLine.prototype.toArray.apply(line3)).eql(line.toArray());
|
||||
assert.deepEqual(TestBufferLine.prototype.toArray.apply(line3), line.toArray());
|
||||
});
|
||||
describe('resize', function(): void {
|
||||
it('enlarge(false)', function(): void {
|
||||
const line = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false);
|
||||
line.resize(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql((Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
assert.deepEqual(line.toArray(), (Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
});
|
||||
it('enlarge(true)', function(): void {
|
||||
const line = new TestBufferLine(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false);
|
||||
line.resize(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql((Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
assert.deepEqual(line.toArray(), (Array(10) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
});
|
||||
it('shrink(true) - should apply new size', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false);
|
||||
line.resize(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql((Array(5) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
assert.deepEqual(line.toArray(), (Array(5) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
});
|
||||
it('shrink to 0 length', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false);
|
||||
line.resize(0, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
expect(line.toArray()).eql((Array(0) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
assert.deepEqual(line.toArray(), (Array(0) as any).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
});
|
||||
it('should remove combining data on replaced cells after shrinking then enlarging', () => {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]), false);
|
||||
line.set(2, [ 0, '😁', 1, '😁'.charCodeAt(0) ]);
|
||||
line.set(9, [ 0, '😁', 1, '😁'.charCodeAt(0) ]);
|
||||
expect(line.translateToString()).eql('aa😁aaaaaa😁');
|
||||
expect(Object.keys(line.combined).length).eql(2);
|
||||
assert.equal(line.translateToString(), 'aa😁aaaaaa😁');
|
||||
assert.equal(Object.keys(line.combined).length, 2);
|
||||
line.resize(5, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
expect(line.translateToString()).eql('aa😁aa');
|
||||
assert.equal(line.translateToString(), 'aa😁aa');
|
||||
line.resize(10, CellData.fromCharData([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||
expect(line.translateToString()).eql('aa😁aaaaaaa');
|
||||
expect(Object.keys(line.combined).length).eql(1);
|
||||
assert.equal(line.translateToString(), 'aa😁aaaaaaa');
|
||||
assert.equal(Object.keys(line.combined).length, 1);
|
||||
});
|
||||
});
|
||||
describe('getTrimLength', function(): void {
|
||||
it('empty line', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
expect(line.getTrimmedLength()).equal(0);
|
||||
assert.equal(line.getTrimmedLength(), 0);
|
||||
});
|
||||
it('ASCII', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(2, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
expect(line.getTrimmedLength()).equal(3);
|
||||
assert.equal(line.getTrimmedLength(), 3);
|
||||
});
|
||||
it('surrogate', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(2, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)]));
|
||||
expect(line.getTrimmedLength()).equal(3);
|
||||
assert.equal(line.getTrimmedLength(), 3);
|
||||
});
|
||||
it('combining', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(2, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)]));
|
||||
expect(line.getTrimmedLength()).equal(3);
|
||||
assert.equal(line.getTrimmedLength(), 3);
|
||||
});
|
||||
it('fullwidth', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(2, CellData.fromCharData([1, '1', 2, '1'.charCodeAt(0)]));
|
||||
line.setCell(3, CellData.fromCharData([0, '', 0, 0]));
|
||||
expect(line.getTrimmedLength()).equal(4); // also counts null cell after fullwidth
|
||||
assert.equal(line.getTrimmedLength(), 4); // also counts null cell after fullwidth
|
||||
});
|
||||
});
|
||||
describe('translateToString with and w\'o trimming', function(): void {
|
||||
it('empty line', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
expect(line.translateToString(false)).equal(' ');
|
||||
expect(line.translateToString(true)).equal('');
|
||||
assert.equal(line.translateToString(false), ' ');
|
||||
assert.equal(line.translateToString(true), '');
|
||||
});
|
||||
it('ASCII', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
@@ -340,14 +340,14 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(2, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(5, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
expect(line.translateToString(false)).equal('a a aa ');
|
||||
expect(line.translateToString(true)).equal('a a aa');
|
||||
expect(line.translateToString(false, 0, 5)).equal('a a a');
|
||||
expect(line.translateToString(false, 0, 4)).equal('a a ');
|
||||
expect(line.translateToString(false, 0, 3)).equal('a a');
|
||||
expect(line.translateToString(true, 0, 5)).equal('a a a');
|
||||
expect(line.translateToString(true, 0, 4)).equal('a a ');
|
||||
expect(line.translateToString(true, 0, 3)).equal('a a');
|
||||
assert.equal(line.translateToString(false), 'a a aa ');
|
||||
assert.equal(line.translateToString(true), 'a a aa');
|
||||
assert.equal(line.translateToString(false, 0, 5), 'a a a');
|
||||
assert.equal(line.translateToString(false, 0, 4), 'a a ');
|
||||
assert.equal(line.translateToString(false, 0, 3), 'a a');
|
||||
assert.equal(line.translateToString(true, 0, 5), 'a a a');
|
||||
assert.equal(line.translateToString(true, 0, 4), 'a a ');
|
||||
assert.equal(line.translateToString(true, 0, 3), 'a a');
|
||||
|
||||
});
|
||||
it('surrogate', function(): void {
|
||||
@@ -356,14 +356,14 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(2, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)]));
|
||||
line.setCell(5, CellData.fromCharData([1, '𝄞', 1, '𝄞'.charCodeAt(0)]));
|
||||
expect(line.translateToString(false)).equal('a 𝄞 𝄞𝄞 ');
|
||||
expect(line.translateToString(true)).equal('a 𝄞 𝄞𝄞');
|
||||
expect(line.translateToString(false, 0, 5)).equal('a 𝄞 𝄞');
|
||||
expect(line.translateToString(false, 0, 4)).equal('a 𝄞 ');
|
||||
expect(line.translateToString(false, 0, 3)).equal('a 𝄞');
|
||||
expect(line.translateToString(true, 0, 5)).equal('a 𝄞 𝄞');
|
||||
expect(line.translateToString(true, 0, 4)).equal('a 𝄞 ');
|
||||
expect(line.translateToString(true, 0, 3)).equal('a 𝄞');
|
||||
assert.equal(line.translateToString(false), 'a 𝄞 𝄞𝄞 ');
|
||||
assert.equal(line.translateToString(true), 'a 𝄞 𝄞𝄞');
|
||||
assert.equal(line.translateToString(false, 0, 5), 'a 𝄞 𝄞');
|
||||
assert.equal(line.translateToString(false, 0, 4), 'a 𝄞 ');
|
||||
assert.equal(line.translateToString(false, 0, 3), 'a 𝄞');
|
||||
assert.equal(line.translateToString(true, 0, 5), 'a 𝄞 𝄞');
|
||||
assert.equal(line.translateToString(true, 0, 4), 'a 𝄞 ');
|
||||
assert.equal(line.translateToString(true, 0, 3), 'a 𝄞');
|
||||
});
|
||||
it('combining', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
@@ -371,14 +371,14 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(2, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)]));
|
||||
line.setCell(4, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)]));
|
||||
line.setCell(5, CellData.fromCharData([1, 'e\u0301', 1, '\u0301'.charCodeAt(0)]));
|
||||
expect(line.translateToString(false)).equal('a e\u0301 e\u0301e\u0301 ');
|
||||
expect(line.translateToString(true)).equal('a e\u0301 e\u0301e\u0301');
|
||||
expect(line.translateToString(false, 0, 5)).equal('a e\u0301 e\u0301');
|
||||
expect(line.translateToString(false, 0, 4)).equal('a e\u0301 ');
|
||||
expect(line.translateToString(false, 0, 3)).equal('a e\u0301');
|
||||
expect(line.translateToString(true, 0, 5)).equal('a e\u0301 e\u0301');
|
||||
expect(line.translateToString(true, 0, 4)).equal('a e\u0301 ');
|
||||
expect(line.translateToString(true, 0, 3)).equal('a e\u0301');
|
||||
assert.equal(line.translateToString(false), 'a e\u0301 e\u0301e\u0301 ');
|
||||
assert.equal(line.translateToString(true), 'a e\u0301 e\u0301e\u0301');
|
||||
assert.equal(line.translateToString(false, 0, 5), 'a e\u0301 e\u0301');
|
||||
assert.equal(line.translateToString(false, 0, 4), 'a e\u0301 ');
|
||||
assert.equal(line.translateToString(false, 0, 3), 'a e\u0301');
|
||||
assert.equal(line.translateToString(true, 0, 5), 'a e\u0301 e\u0301');
|
||||
assert.equal(line.translateToString(true, 0, 4), 'a e\u0301 ');
|
||||
assert.equal(line.translateToString(true, 0, 3), 'a e\u0301');
|
||||
});
|
||||
it('fullwidth', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
@@ -389,20 +389,20 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(6, CellData.fromCharData([0, '', 0, 0]));
|
||||
line.setCell(7, CellData.fromCharData([1, '1', 2, '1'.charCodeAt(0)]));
|
||||
line.setCell(8, CellData.fromCharData([0, '', 0, 0]));
|
||||
expect(line.translateToString(false)).equal('a 1 11 ');
|
||||
expect(line.translateToString(true)).equal('a 1 11');
|
||||
expect(line.translateToString(false, 0, 7)).equal('a 1 1');
|
||||
expect(line.translateToString(false, 0, 6)).equal('a 1 1');
|
||||
expect(line.translateToString(false, 0, 5)).equal('a 1 ');
|
||||
expect(line.translateToString(false, 0, 4)).equal('a 1');
|
||||
expect(line.translateToString(false, 0, 3)).equal('a 1');
|
||||
expect(line.translateToString(false, 0, 2)).equal('a ');
|
||||
expect(line.translateToString(true, 0, 7)).equal('a 1 1');
|
||||
expect(line.translateToString(true, 0, 6)).equal('a 1 1');
|
||||
expect(line.translateToString(true, 0, 5)).equal('a 1 ');
|
||||
expect(line.translateToString(true, 0, 4)).equal('a 1');
|
||||
expect(line.translateToString(true, 0, 3)).equal('a 1');
|
||||
expect(line.translateToString(true, 0, 2)).equal('a ');
|
||||
assert.equal(line.translateToString(false), 'a 1 11 ');
|
||||
assert.equal(line.translateToString(true), 'a 1 11');
|
||||
assert.equal(line.translateToString(false, 0, 7), 'a 1 1');
|
||||
assert.equal(line.translateToString(false, 0, 6), 'a 1 1');
|
||||
assert.equal(line.translateToString(false, 0, 5), 'a 1 ');
|
||||
assert.equal(line.translateToString(false, 0, 4), 'a 1');
|
||||
assert.equal(line.translateToString(false, 0, 3), 'a 1');
|
||||
assert.equal(line.translateToString(false, 0, 2), 'a ');
|
||||
assert.equal(line.translateToString(true, 0, 7), 'a 1 1');
|
||||
assert.equal(line.translateToString(true, 0, 6), 'a 1 1');
|
||||
assert.equal(line.translateToString(true, 0, 5), 'a 1 ');
|
||||
assert.equal(line.translateToString(true, 0, 4), 'a 1');
|
||||
assert.equal(line.translateToString(true, 0, 3), 'a 1');
|
||||
assert.equal(line.translateToString(true, 0, 2), 'a ');
|
||||
});
|
||||
it('space at end', function(): void {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]), false);
|
||||
@@ -411,21 +411,21 @@ describe('BufferLine', function(): void {
|
||||
line.setCell(4, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(5, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
line.setCell(6, CellData.fromCharData([1, ' ', 1, ' '.charCodeAt(0)]));
|
||||
expect(line.translateToString(false)).equal('a a aa ');
|
||||
expect(line.translateToString(true)).equal('a a aa ');
|
||||
assert.equal(line.translateToString(false), 'a a aa ');
|
||||
assert.equal(line.translateToString(true), 'a a aa ');
|
||||
});
|
||||
it('should always return some sane value', function(): void {
|
||||
// sanity check - broken line with invalid out of bound null width cells
|
||||
// this can atm happen with deleting/inserting chars in inputhandler by "breaking"
|
||||
// fullwidth pairs --> needs to be fixed after settling BufferLine impl
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, 0, NULL_CELL_CODE]), false);
|
||||
expect(line.translateToString(false)).equal(' ');
|
||||
expect(line.translateToString(true)).equal('');
|
||||
assert.equal(line.translateToString(false), ' ');
|
||||
assert.equal(line.translateToString(true), '');
|
||||
});
|
||||
it('should work with endCol=0', () => {
|
||||
const line = new TestBufferLine(10, CellData.fromCharData([DEFAULT_ATTR, NULL_CELL_CHAR, 0, NULL_CELL_CODE]), false);
|
||||
line.setCell(0, CellData.fromCharData([1, 'a', 1, 'a'.charCodeAt(0)]));
|
||||
expect(line.translateToString(true, 0, 0)).equal('');
|
||||
assert.equal(line.translateToString(true, 0, 0), '');
|
||||
});
|
||||
});
|
||||
describe('addCharToCell', () => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user