This commit is contained in:
Jörg Breitbart
2016-07-05 23:54:15 +02:00
parent 39c4356ef6
commit 4afa08da8d
2 changed files with 340 additions and 266 deletions
+49 -22
View File
@@ -252,7 +252,7 @@
this.applicationCursor = false; this.applicationCursor = false;
this.originMode = false; this.originMode = false;
this.insertMode = false; this.insertMode = false;
this.wraparoundMode = false; this.wraparoundMode = true; // defaults: xterm - true, vt100 - false
this.normal = null; this.normal = null;
// charset // charset
@@ -1464,7 +1464,7 @@
* @public * @public
*/ */
Terminal.prototype.write = function(data) { Terminal.prototype.write = function(data) {
var l = data.length, i = 0, j, cs, ch, code, low, ch_width; var l = data.length, i = 0, j, cs, ch, code, low, ch_width, row;
this.refreshStart = this.y; this.refreshStart = this.y;
this.refreshEnd = this.y; this.refreshEnd = this.y;
@@ -1566,20 +1566,22 @@
ch = this.charset[ch]; ch = this.charset[ch];
} }
row = this.y + this.ybase;
// insert combining char in last cell // insert combining char in last cell
// FIXME: needs handling after cursor jumps // FIXME: needs handling after cursor jumps
if (!ch_width && this.x) { if (!ch_width && this.x) {
// dont overflow left // dont overflow left
if (this.lines[this.y + this.ybase][this.x-1]) { if (this.lines[row][this.x-1]) {
if (!this.lines[this.y + this.ybase][this.x-1][2]) { if (!this.lines[row][this.x-1][2]) {
// found empty cell after fullwidth, need to go 2 cells back // found empty cell after fullwidth, need to go 2 cells back
if (this.lines[this.y + this.ybase][this.x-2]) if (this.lines[row][this.x-2])
this.lines[this.y + this.ybase][this.x-2][1] += ch; this.lines[row][this.x-2][1] += ch;
} else { } else {
this.lines[this.y + this.ybase][this.x-1][1] += ch; this.lines[row][this.x-1][1] += ch;
} }
this.updateRange(this.y); this.updateRange(this.y);
} }
@@ -1589,21 +1591,46 @@
// goto next line if ch would overflow // goto next line if ch would overflow
// TODO: needs a global min terminal width of 2 // TODO: needs a global min terminal width of 2
if (this.x+ch_width-1 >= this.cols) { if (this.x+ch_width-1 >= this.cols) {
this.x = 0; // autowrap - DECAWM
this.y++; if (this.wraparoundMode) {
if (this.y > this.scrollBottom) { this.x = 0;
this.y--; this.y++;
this.scroll(); if (this.y > this.scrollBottom) {
this.y--;
this.scroll();
}
} else {
this.x = this.cols-1;
if(ch_width===2) // FIXME: check for xterm behavior
continue;
}
}
row = this.y + this.ybase;
// insert mode: move characters to right
if (this.insertMode) {
// do this twice for a fullwidth char
for (var 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
var removed = this.lines[this.y + this.ybase].pop();
if (removed[2]===0
&& this.lines[row][this.cols-2]
&& this.lines[row][this.cols-2][2]===2)
this.lines[row][this.cols-2] = [this.curAttr, ' ', 1];
// insert empty cell at cursor
this.lines[row].splice(this.x, 0, [this.curAttr, ' ', 1]);
} }
} }
this.lines[this.y + this.ybase][this.x] = [this.curAttr, ch, ch_width]; this.lines[row][this.x] = [this.curAttr, ch, ch_width];
this.x++; this.x++;
this.updateRange(this.y); this.updateRange(this.y);
// fullwidth char - set next cell width to zero and advance cursor // fullwidth char - set next cell width to zero and advance cursor
if (ch_width==2) { if (ch_width===2) {
this.lines[this.y + this.ybase][this.x] = [this.curAttr, '', 0]; this.lines[row][this.x] = [this.curAttr, '', 0];
this.x++; this.x++;
} }
} }
@@ -3463,7 +3490,7 @@
row = this.y + this.ybase; row = this.y + this.ybase;
j = this.x; j = this.x;
ch = [this.eraseAttr(), ' ']; // xterm ch = [this.eraseAttr(), ' ', 1]; // xterm
while (param-- && j < this.cols) { while (param-- && j < this.cols) {
this.lines[row].splice(j++, 0, ch); this.lines[row].splice(j++, 0, ch);
@@ -3560,7 +3587,7 @@
if (param < 1) param = 1; if (param < 1) param = 1;
row = this.y + this.ybase; row = this.y + this.ybase;
ch = [this.eraseAttr(), ' ']; // xterm ch = [this.eraseAttr(), ' ', 1]; // xterm
while (param--) { while (param--) {
this.lines[row].splice(this.x, 1); this.lines[row].splice(this.x, 1);
@@ -3578,7 +3605,7 @@
row = this.y + this.ybase; row = this.y + this.ybase;
j = this.x; j = this.x;
ch = [this.eraseAttr(), ' ']; // xterm ch = [this.eraseAttr(), ' ', 1]; // xterm
while (param-- && j < this.cols) { while (param-- && j < this.cols) {
this.lines[row][j++] = ch; this.lines[row][j++] = ch;
@@ -4192,7 +4219,7 @@
Terminal.prototype.repeatPrecedingCharacter = function(params) { Terminal.prototype.repeatPrecedingCharacter = function(params) {
var param = params[0] || 1 var param = params[0] || 1
, line = this.lines[this.ybase + this.y] , line = this.lines[this.ybase + this.y]
, ch = line[this.x - 1] || [this.defAttr, ' ']; , ch = line[this.x - 1] || [this.defAttr, ' ', 1];
while (param--) line[this.x++] = ch; while (param--) line[this.x++] = ch;
}; };
@@ -4454,7 +4481,7 @@
, i , i
, ch; , ch;
ch = [this.eraseAttr(), ' ']; // xterm? ch = [this.eraseAttr(), ' ', 1]; // xterm?
for (; t < b + 1; t++) { for (; t < b + 1; t++) {
line = this.lines[this.ybase + t]; line = this.lines[this.ybase + t];
@@ -4475,7 +4502,7 @@
Terminal.prototype.insertColumns = function() { Terminal.prototype.insertColumns = function() {
var param = params[0] var param = params[0]
, l = this.ybase + this.rows , l = this.ybase + this.rows
, ch = [this.eraseAttr(), ' '] // xterm? , ch = [this.eraseAttr(), ' ', 1] // xterm?
, i; , i;
while (param--) { while (param--) {
@@ -4495,7 +4522,7 @@
Terminal.prototype.deleteColumns = function() { Terminal.prototype.deleteColumns = function() {
var param = params[0] var param = params[0]
, l = this.ybase + this.rows , l = this.ybase + this.rows
, ch = [this.eraseAttr(), ' '] // xterm? , ch = [this.eraseAttr(), ' ', 1] // xterm?
, i; , i;
while (param--) { while (param--) {
+291 -244
View File
@@ -1,5 +1,5 @@
var assert = require('chai').assert; var assert = require('chai').assert;
var chai = require('chai'); var expect = require('chai').expect;
var Terminal = require('../src/xterm'); var Terminal = require('../src/xterm');
describe('xterm.js', function() { describe('xterm.js', function() {
@@ -192,260 +192,307 @@ describe('xterm.js', function() {
}); });
}); });
describe('unicode - surrogates', function() { describe('unicode - surrogates', function() {
it('2 characters per cell', function () { it('2 characters per cell', function () {
var high = '\uD800'; var high = '\uD800';
for (var i=0xDC00; i<=0xDCFF; ++i) { for (var i=0xDC00; i<=0xDCFF; ++i) {
xterm.write(high + String.fromCharCode(i)); xterm.write(high + String.fromCharCode(i));
var tchar = xterm.lines[0][0]; var tchar = xterm.lines[0][0];
chai.expect(tchar[1]).eql(high + String.fromCharCode(i)); expect(tchar[1]).eql(high + String.fromCharCode(i));
chai.expect(tchar[1].length).eql(2); expect(tchar[1].length).eql(2);
chai.expect(tchar[2]).eql(1); expect(tchar[2]).eql(1);
chai.expect(xterm.lines[0][1][1]).eql(' '); expect(xterm.lines[0][1][1]).eql(' ');
xterm.reset(); xterm.reset();
} }
}); });
it('2 characters at last cell', function () { it('2 characters at last cell', function() {
var high = '\uD800'; var high = '\uD800';
for (var i=0xDC00; i<=0xDCFF; ++i) { for (var i=0xDC00; i<=0xDCFF; ++i) {
xterm.x = xterm.cols - 1; xterm.x = xterm.cols - 1;
xterm.write(high + String.fromCharCode(i)); xterm.write(high + String.fromCharCode(i));
chai.expect(xterm.lines[0][xterm.x-1][1]).eql(high + String.fromCharCode(i)); expect(xterm.lines[0][xterm.x-1][1]).eql(high + String.fromCharCode(i));
chai.expect(xterm.lines[0][xterm.x-1][1].length).eql(2); expect(xterm.lines[0][xterm.x-1][1].length).eql(2);
chai.expect(xterm.lines[1][0][1]).eql(' '); expect(xterm.lines[1][0][1]).eql(' ');
xterm.reset(); xterm.reset();
} }
}); });
it('2 characters per cell over line end with autowrap', function () { it('2 characters per cell over line end with autowrap', function() {
var high = '\uD800'; var high = '\uD800';
for (var i=0xDC00; i<=0xDCFF; ++i) { for (var i=0xDC00; i<=0xDCFF; ++i) {
xterm.x = xterm.cols - 1; xterm.x = xterm.cols - 1;
xterm.wraparoundMode = true; xterm.wraparoundMode = true;
xterm.write('a' + high + String.fromCharCode(i)); xterm.write('a' + high + String.fromCharCode(i));
chai.expect(xterm.lines[0][xterm.cols-1][1]).eql('a'); expect(xterm.lines[0][xterm.cols-1][1]).eql('a');
chai.expect(xterm.lines[1][0][1]).eql(high + String.fromCharCode(i)); expect(xterm.lines[1][0][1]).eql(high + String.fromCharCode(i));
chai.expect(xterm.lines[1][0][1].length).eql(2); expect(xterm.lines[1][0][1].length).eql(2);
chai.expect(xterm.lines[1][1][1]).eql(' '); expect(xterm.lines[1][1][1]).eql(' ');
xterm.reset(); xterm.reset();
} }
}); });
/** FIXME - wrap is not respected in default state */ it('2 characters per cell over line end without autowrap', function() {
/* var high = '\uD800';
it('2 characters per cell over line end without autowrap', function () { for (var i=0xDC00; i<=0xDCFF; ++i) {
var high = '\uD800'; xterm.x = xterm.cols - 1;
for (var i=0xDC00; i<=0xDCFF; ++i) { xterm.wraparoundMode = false;
xterm.x = xterm.cols - 1; xterm.write('a' + high + String.fromCharCode(i));
xterm.wraparoundMode = false; expect(xterm.lines[0][xterm.cols-1][1]).eql(high + String.fromCharCode(i));
xterm.write('a' + high + String.fromCharCode(i)); expect(xterm.lines[0][xterm.cols-1][1].length).eql(2);
chai.expect(xterm.lines[0][xterm.cols-1][1]).eql(high + String.fromCharCode(i)); expect(xterm.lines[1][1][1]).eql(' ');
chai.expect(xterm.lines[0][xterm.cols-1][1].length).eql(2); xterm.reset();
chai.expect(xterm.lines[1][1][1]).eql(' '); }
xterm.reset();
}
}); });
*/ it('splitted surrogates', function() {
it('splitted surrogates', function () { var high = '\uD800';
var high = '\uD800'; for (var i=0xDC00; i<=0xDCFF; ++i) {
for (var i=0xDC00; i<=0xDCFF; ++i) { xterm.write(high);
xterm.write(high); xterm.write(String.fromCharCode(i));
xterm.write(String.fromCharCode(i)); var tchar = xterm.lines[0][0];
var tchar = xterm.lines[0][0]; expect(tchar[1]).eql(high + String.fromCharCode(i));
chai.expect(tchar[1]).eql(high + String.fromCharCode(i)); expect(tchar[1].length).eql(2);
chai.expect(tchar[1].length).eql(2); expect(tchar[2]).eql(1);
chai.expect(tchar[2]).eql(1); expect(xterm.lines[0][1][1]).eql(' ');
chai.expect(xterm.lines[0][1][1]).eql(' '); xterm.reset();
xterm.reset(); }
}
}); });
}); });
describe('unicode - combining characters', function() {
describe('unicode - combining characters', function() {
it('café', function () { it('café', function () {
xterm.write('cafe\u0301'); xterm.write('cafe\u0301');
chai.expect(xterm.lines[0][3][1]).eql('e\u0301'); expect(xterm.lines[0][3][1]).eql('e\u0301');
chai.expect(xterm.lines[0][3][1].length).eql(2); expect(xterm.lines[0][3][1].length).eql(2);
chai.expect(xterm.lines[0][3][2]).eql(1); expect(xterm.lines[0][3][2]).eql(1);
}); });
it('café - end of line', function () { it('café - end of line', function() {
xterm.x = xterm.cols - 1 - 3; xterm.x = xterm.cols - 1 - 3;
xterm.write('cafe\u0301'); xterm.write('cafe\u0301');
chai.expect(xterm.lines[0][xterm.cols-1][1]).eql('e\u0301'); expect(xterm.lines[0][xterm.cols-1][1]).eql('e\u0301');
chai.expect(xterm.lines[0][xterm.cols-1][1].length).eql(2); expect(xterm.lines[0][xterm.cols-1][1].length).eql(2);
chai.expect(xterm.lines[0][xterm.cols-1][2]).eql(1); expect(xterm.lines[0][xterm.cols-1][2]).eql(1);
chai.expect(xterm.lines[0][1][1]).eql(' '); expect(xterm.lines[0][1][1]).eql(' ');
chai.expect(xterm.lines[0][1][1].length).eql(1); expect(xterm.lines[0][1][1].length).eql(1);
chai.expect(xterm.lines[0][1][2]).eql(1); expect(xterm.lines[0][1][2]).eql(1);
}); });
it('multiple combined é', function () { it('multiple combined é', function() {
xterm.write(Array(100).join('e\u0301')); xterm.wraparoundMode = true;
for (var i=0; i<xterm.cols; ++i) { xterm.write(Array(100).join('e\u0301'));
var tchar = xterm.lines[0][i]; for (var i=0; i<xterm.cols; ++i) {
chai.expect(tchar[1]).eql('e\u0301'); var tchar = xterm.lines[0][i];
chai.expect(tchar[1].length).eql(2); expect(tchar[1]).eql('e\u0301');
chai.expect(tchar[2]).eql(1); expect(tchar[1].length).eql(2);
expect(tchar[2]).eql(1);
}
tchar = xterm.lines[1][0];
expect(tchar[1]).eql('e\u0301');
expect(tchar[1].length).eql(2);
expect(tchar[2]).eql(1);
});
it('multiple surrogate with combined', function() {
xterm.wraparoundMode = true;
xterm.write(Array(100).join('\uD800\uDC00\u0301'));
for (var i=0; i<xterm.cols; ++i) {
var tchar = xterm.lines[0][i];
expect(tchar[1]).eql('\uD800\uDC00\u0301');
expect(tchar[1].length).eql(3);
expect(tchar[2]).eql(1);
}
tchar = xterm.lines[1][0];
expect(tchar[1]).eql('\uD800\uDC00\u0301');
expect(tchar[1].length).eql(3);
expect(tchar[2]).eql(1);
});
});
describe('unicode - fullwidth characters', function() {
it('cursor movement even', function() {
expect(xterm.x).eql(0);
xterm.write('¥');
expect(xterm.x).eql(2);
});
it('cursor movement odd', function() {
xterm.x = 1;
expect(xterm.x).eql(1);
xterm.write('¥');
expect(xterm.x).eql(3);
});
it('line of ¥ even', function() {
xterm.wraparoundMode = true;
xterm.write(Array(50).join('¥'));
for (var i=0; i<xterm.cols; ++i) {
var tchar = xterm.lines[0][i];
if (i % 2) {
expect(tchar[1]).eql('');
expect(tchar[1].length).eql(0);
expect(tchar[2]).eql(0);
} else {
expect(tchar[1]).eql('¥');
expect(tchar[1].length).eql(1);
expect(tchar[2]).eql(2);
} }
tchar = xterm.lines[1][0]; }
chai.expect(tchar[1]).eql('e\u0301'); tchar = xterm.lines[1][0];
chai.expect(tchar[1].length).eql(2); expect(tchar[1]).eql('¥');
chai.expect(tchar[2]).eql(1); expect(tchar[1].length).eql(1);
expect(tchar[2]).eql(2);
}); });
it('multiple surrogate with combined', function () { it('line of ¥ odd', function() {
xterm.write(Array(100).join('\uD800\uDC00\u0301')); xterm.wraparoundMode = true;
for (var i=0; i<xterm.cols; ++i) { xterm.x = 1;
var tchar = xterm.lines[0][i]; xterm.write(Array(50).join('¥'));
chai.expect(tchar[1]).eql('\uD800\uDC00\u0301'); for (var i=1; i<xterm.cols-1; ++i) {
chai.expect(tchar[1].length).eql(3); var tchar = xterm.lines[0][i];
chai.expect(tchar[2]).eql(1); if (!(i % 2)) {
expect(tchar[1]).eql('');
expect(tchar[1].length).eql(0);
expect(tchar[2]).eql(0);
} else {
expect(tchar[1]).eql('¥');
expect(tchar[1].length).eql(1);
expect(tchar[2]).eql(2);
} }
tchar = xterm.lines[1][0]; }
chai.expect(tchar[1]).eql('\uD800\uDC00\u0301'); tchar = xterm.lines[0][xterm.cols-1];
chai.expect(tchar[1].length).eql(3); expect(tchar[1]).eql(' ');
chai.expect(tchar[2]).eql(1); expect(tchar[1].length).eql(1);
expect(tchar[2]).eql(1);
tchar = xterm.lines[1][0];
expect(tchar[1]).eql('¥');
expect(tchar[1].length).eql(1);
expect(tchar[2]).eql(2);
}); });
}); it('line of ¥ with combining odd', function() {
xterm.wraparoundMode = true;
describe('unicode - fullwidth characters', function() { xterm.x = 1;
it('cursor movement even', function () { xterm.write(Array(50).join('¥\u0301'));
chai.expect(xterm.x).eql(0); for (var i=1; i<xterm.cols-1; ++i) {
xterm.write('¥'); var tchar = xterm.lines[0][i];
chai.expect(xterm.x).eql(2); if (!(i % 2)) {
}); expect(tchar[1]).eql('');
it('cursor movement odd', function () { expect(tchar[1].length).eql(0);
xterm.x = 1; expect(tchar[2]).eql(0);
chai.expect(xterm.x).eql(1); } else {
xterm.write('¥'); expect(tchar[1]).eql('¥\u0301');
chai.expect(xterm.x).eql(3); expect(tchar[1].length).eql(2);
}); expect(tchar[2]).eql(2);
it('line of ¥ even', function () { }
xterm.write(Array(50).join('¥')); }
for (var i=0; i<xterm.cols; ++i) { tchar = xterm.lines[0][xterm.cols-1];
var tchar = xterm.lines[0][i]; expect(tchar[1]).eql(' ');
if (i % 2) { expect(tchar[1].length).eql(1);
chai.expect(tchar[1]).eql(''); expect(tchar[2]).eql(1);
chai.expect(tchar[1].length).eql(0); tchar = xterm.lines[1][0];
chai.expect(tchar[2]).eql(0); expect(tchar[1]).eql('¥\u0301');
} else { expect(tchar[1].length).eql(2);
chai.expect(tchar[1]).eql('¥'); expect(tchar[2]).eql(2);
chai.expect(tchar[1].length).eql(1); });
chai.expect(tchar[2]).eql(2); it('line of ¥ with combining even', function() {
} xterm.wraparoundMode = true;
} xterm.write(Array(50).join('¥\u0301'));
tchar = xterm.lines[1][0]; for (var i=0; i<xterm.cols; ++i) {
chai.expect(tchar[1]).eql('¥'); var tchar = xterm.lines[0][i];
chai.expect(tchar[1].length).eql(1); if (i % 2) {
chai.expect(tchar[2]).eql(2); expect(tchar[1]).eql('');
}); expect(tchar[1].length).eql(0);
it('line of ¥ odd', function () { expect(tchar[2]).eql(0);
xterm.x = 1; } else {
xterm.write(Array(50).join('¥')); expect(tchar[1]).eql('¥\u0301');
for (var i=1; i<xterm.cols-1; ++i) { expect(tchar[1].length).eql(2);
var tchar = xterm.lines[0][i]; expect(tchar[2]).eql(2);
if (!(i % 2)) { }
chai.expect(tchar[1]).eql(''); }
chai.expect(tchar[1].length).eql(0); tchar = xterm.lines[1][0];
chai.expect(tchar[2]).eql(0); expect(tchar[1]).eql('¥\u0301');
} else { expect(tchar[1].length).eql(2);
chai.expect(tchar[1]).eql('¥'); expect(tchar[2]).eql(2);
chai.expect(tchar[1].length).eql(1); });
chai.expect(tchar[2]).eql(2); it('line of surrogate fullwidth with combining odd', function() {
} xterm.wraparoundMode = true;
} xterm.x = 1;
tchar = xterm.lines[0][xterm.cols-1]; xterm.write(Array(50).join('\ud843\ude6d\u0301'));
chai.expect(tchar[1]).eql(' '); for (var i=1; i<xterm.cols-1; ++i) {
chai.expect(tchar[1].length).eql(1); var tchar = xterm.lines[0][i];
chai.expect(tchar[2]).eql(1); if (!(i % 2)) {
tchar = xterm.lines[1][0]; expect(tchar[1]).eql('');
chai.expect(tchar[1]).eql('¥'); expect(tchar[1].length).eql(0);
chai.expect(tchar[1].length).eql(1); expect(tchar[2]).eql(0);
chai.expect(tchar[2]).eql(2); } else {
}); expect(tchar[1]).eql('\ud843\ude6d\u0301');
it('line of ¥ with combining odd', function () { expect(tchar[1].length).eql(3);
xterm.x = 1; expect(tchar[2]).eql(2);
xterm.write(Array(50).join('¥\u0301')); }
for (var i=1; i<xterm.cols-1; ++i) { }
var tchar = xterm.lines[0][i]; tchar = xterm.lines[0][xterm.cols-1];
if (!(i % 2)) { expect(tchar[1]).eql(' ');
chai.expect(tchar[1]).eql(''); expect(tchar[1].length).eql(1);
chai.expect(tchar[1].length).eql(0); expect(tchar[2]).eql(1);
chai.expect(tchar[2]).eql(0); tchar = xterm.lines[1][0];
} else { expect(tchar[1]).eql('\ud843\ude6d\u0301');
chai.expect(tchar[1]).eql('¥\u0301'); expect(tchar[1].length).eql(3);
chai.expect(tchar[1].length).eql(2); expect(tchar[2]).eql(2);
chai.expect(tchar[2]).eql(2); });
} it('line of surrogate fullwidth with combining even', function() {
} xterm.wraparoundMode = true;
tchar = xterm.lines[0][xterm.cols-1]; xterm.write(Array(50).join('\ud843\ude6d\u0301'));
chai.expect(tchar[1]).eql(' '); for (var i=0; i<xterm.cols; ++i) {
chai.expect(tchar[1].length).eql(1); var tchar = xterm.lines[0][i];
chai.expect(tchar[2]).eql(1); if (i % 2) {
tchar = xterm.lines[1][0]; expect(tchar[1]).eql('');
chai.expect(tchar[1]).eql('¥\u0301'); expect(tchar[1].length).eql(0);
chai.expect(tchar[1].length).eql(2); expect(tchar[2]).eql(0);
chai.expect(tchar[2]).eql(2); } else {
}); expect(tchar[1]).eql('\ud843\ude6d\u0301');
it('line of ¥ with combining even', function () { expect(tchar[1].length).eql(3);
xterm.write(Array(50).join('¥\u0301')); expect(tchar[2]).eql(2);
for (var i=0; i<xterm.cols; ++i) { }
var tchar = xterm.lines[0][i]; }
if (i % 2) { tchar = xterm.lines[1][0];
chai.expect(tchar[1]).eql(''); expect(tchar[1]).eql('\ud843\ude6d\u0301');
chai.expect(tchar[1].length).eql(0); expect(tchar[1].length).eql(3);
chai.expect(tchar[2]).eql(0); expect(tchar[2]).eql(2);
} else { });
chai.expect(tchar[1]).eql('¥\u0301'); });
chai.expect(tchar[1].length).eql(2);
chai.expect(tchar[2]).eql(2); describe('insert mode', function() {
} it('halfwidth - all', function () {
} xterm.write(Array(9).join('0123456789').slice(-80));
tchar = xterm.lines[1][0]; xterm.x = 10;
chai.expect(tchar[1]).eql('¥\u0301'); xterm.y = 0;
chai.expect(tchar[1].length).eql(2); xterm.insertMode = true;
chai.expect(tchar[2]).eql(2); xterm.write('abcde');
}); expect(xterm.lines[0].length).eql(xterm.cols);
it('line of surrogate fullwidth with combining odd', function () { expect(xterm.lines[0][10][1]).eql('a');
xterm.x = 1; expect(xterm.lines[0][14][1]).eql('e');
xterm.write(Array(50).join('\ud843\ude6d\u0301')); expect(xterm.lines[0][15][1]).eql('0');
for (var i=1; i<xterm.cols-1; ++i) { expect(xterm.lines[0][79][1]).eql('4');
var tchar = xterm.lines[0][i]; });
if (!(i % 2)) { it('fullwidth - insert', function() {
chai.expect(tchar[1]).eql(''); xterm.write(Array(9).join('0123456789').slice(-80));
chai.expect(tchar[1].length).eql(0); xterm.x = 10;
chai.expect(tchar[2]).eql(0); xterm.y = 0;
} else { xterm.insertMode = true;
chai.expect(tchar[1]).eql('\ud843\ude6d\u0301'); xterm.write('¥¥¥');
chai.expect(tchar[1].length).eql(3); expect(xterm.lines[0].length).eql(xterm.cols);
chai.expect(tchar[2]).eql(2); expect(xterm.lines[0][10][1]).eql('¥');
} expect(xterm.lines[0][11][1]).eql('');
} expect(xterm.lines[0][14][1]).eql('¥');
tchar = xterm.lines[0][xterm.cols-1]; expect(xterm.lines[0][15][1]).eql('');
chai.expect(tchar[1]).eql(' '); expect(xterm.lines[0][79][1]).eql('3');
chai.expect(tchar[1].length).eql(1); });
chai.expect(tchar[2]).eql(1); it('fullwidth - right border', function() {
tchar = xterm.lines[1][0]; xterm.write(Array(41).join('¥'));
chai.expect(tchar[1]).eql('\ud843\ude6d\u0301'); xterm.x = 10;
chai.expect(tchar[1].length).eql(3); xterm.y = 0;
chai.expect(tchar[2]).eql(2); xterm.insertMode = true;
}); xterm.write('a');
it('line of surrogate fullwidth with combining even', function () { expect(xterm.lines[0].length).eql(xterm.cols);
xterm.write(Array(50).join('\ud843\ude6d\u0301')); expect(xterm.lines[0][10][1]).eql('a');
for (var i=0; i<xterm.cols; ++i) { expect(xterm.lines[0][11][1]).eql('¥');
var tchar = xterm.lines[0][i]; expect(xterm.lines[0][79][1]).eql(' '); // fullwidth char got replaced
if (i % 2) { xterm.write('b');
chai.expect(tchar[1]).eql(''); expect(xterm.lines[0].length).eql(xterm.cols);
chai.expect(tchar[1].length).eql(0); expect(xterm.lines[0][11][1]).eql('b');
chai.expect(tchar[2]).eql(0); expect(xterm.lines[0][12][1]).eql('¥');
} else { expect(xterm.lines[0][79][1]).eql(''); // empty cell after fullwidth
chai.expect(tchar[1]).eql('\ud843\ude6d\u0301'); });
chai.expect(tchar[1].length).eql(3); });
chai.expect(tchar[2]).eql(2);
}
}
tchar = xterm.lines[1][0];
chai.expect(tchar[1]).eql('\ud843\ude6d\u0301');
chai.expect(tchar[1].length).eql(3);
chai.expect(tchar[2]).eql(2);
});
});
}); });