]> git.proxmox.com Git - mirror_xterm.js.git/blame - test/test.js
Merge remote-tracking branch 'upstream/master' into 118_support_custom_keydown_handler
[mirror_xterm.js.git] / test / test.js
CommitLineData
fa093e2b 1var assert = require('chai').assert;
4afa08da 2var expect = require('chai').expect;
3a866cf2 3var Terminal = require('../src/xterm');
fa093e2b 4
3a866cf2
DI
5describe('xterm.js', function() {
6 var xterm;
fa093e2b 7
3a866cf2
DI
8 beforeEach(function () {
9 xterm = new Terminal();
246b0eda 10 xterm.refresh = function(){};
3a866cf2
DI
11 });
12
13 describe('evaluateKeyEscapeSequence', function() {
0535f942
DI
14 it('should return the correct escape sequence for unmodified keys', function() {
15 // Backspace
16 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 8 }).key, '\x7f'); // ^?
17 // Tab
18 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 9 }).key, '\t');
19 // Return/enter
20 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 13 }).key, '\r'); // CR
21 // Escape
22 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 27 }).key, '\x1b');
23 // Page up, page down
24 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 33 }).key, '\x1b[5~'); // CSI 5 ~
25 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 34 }).key, '\x1b[6~'); // CSI 6 ~
26 // End, Home
8e7eeff4
JB
27 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 35 }).key, '\x1b[F'); // SS3 F
28 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 36 }).key, '\x1b[H'); // SS3 H
0535f942
DI
29 // Left, up, right, down arrows
30 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 37 }).key, '\x1b[D'); // CSI D
31 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 38 }).key, '\x1b[A'); // CSI A
32 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 39 }).key, '\x1b[C'); // CSI C
33 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 40 }).key, '\x1b[B'); // CSI B
34 // Insert
35 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 45 }).key, '\x1b[2~'); // CSI 2 ~
36 // Delete
37 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 46 }).key, '\x1b[3~'); // CSI 3 ~
38 // F1-F12
39 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 112 }).key, '\x1bOP'); // SS3 P
40 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 113 }).key, '\x1bOQ'); // SS3 Q
41 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 114 }).key, '\x1bOR'); // SS3 R
42 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 115 }).key, '\x1bOS'); // SS3 S
43 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 116 }).key, '\x1b[15~'); // CSI 1 5 ~
44 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 117 }).key, '\x1b[17~'); // CSI 1 7 ~
45 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 118 }).key, '\x1b[18~'); // CSI 1 8 ~
46 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 119 }).key, '\x1b[19~'); // CSI 1 9 ~
47 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 120 }).key, '\x1b[20~'); // CSI 2 0 ~
48 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 121 }).key, '\x1b[21~'); // CSI 2 1 ~
49 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 122 }).key, '\x1b[23~'); // CSI 2 3 ~
50 assert.equal(xterm.evaluateKeyEscapeSequence({ keyCode: 123 }).key, '\x1b[24~'); // CSI 2 4 ~
3a866cf2 51 });
0535f942 52 it('should return \\x1b[5D for ctrl+left', function() {
8e7eeff4 53 assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 37 }).key, '\x1b[1;5D'); // CSI 5 D
c86fd878 54 });
0535f942 55 it('should return \\x1b[5C for ctrl+right', function() {
8e7eeff4 56 assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 39 }).key, '\x1b[1;5C'); // CSI 5 C
3a866cf2
DI
57 });
58 });
fed92ac5 59
9cb5b005
DI
60 describe('attachCustomEventHandler', function () {
61 var evKeyDown = {
62 preventDefault: function() {},
63 stopPropagation: function() {},
64 type: 'keydown'
65 }
66
67 beforeEach(function() {
68 xterm.handler = function() {};
69 xterm.showCursor = function() {};
70 xterm.clearSelection = function() {};
71 });
72
73 it('should process the keydown event based on what the handler returns', function () {
74 assert.equal(xterm.keyDown(Object.assign({}, evKeyDown, { keyCode: 77 })), true);
75 xterm.attachCustomKeydownHandler(function (ev) {
76 return ev.keyCode === 77;
77 });
78 assert.equal(xterm.keyDown(Object.assign({}, evKeyDown, { keyCode: 77 })), true);
79 xterm.attachCustomKeydownHandler(function (ev) {
80 return ev.keyCode !== 77;
81 });
82 assert.equal(xterm.keyDown(Object.assign({}, evKeyDown, { keyCode: 77 })), false);
83 });
84 });
85
fed92ac5
PK
86 describe('evaluateCopiedTextProcessing', function () {
87 it('should strip trailing whitespaces and replace nbsps with spaces', function () {
88 var nonBreakingSpace = String.fromCharCode(160),
89 copiedText = 'echo' + nonBreakingSpace + 'hello' + nonBreakingSpace,
90 processedText = Terminal.prepareCopiedTextForClipboard(copiedText);
91
92 // No trailing spaces
93 assert.equal(processedText.match(/\s+$/), null);
94
95 // No non-breaking space
96 assert.equal(processedText.indexOf(nonBreakingSpace), -1);
97 });
98 });
b01165c1 99
100 describe('Third level shift', function() {
6663a947
PK
101 var evKeyDown = {
102 preventDefault: function() {},
103 stopPropagation: function() {},
104 type: 'keydown'
105 },
106 evKeyPress = {
107 preventDefault: function() {},
108 stopPropagation: function() {},
109 type: 'keypress'
110 };
b01165c1 111
112 beforeEach(function() {
113 xterm.handler = function() {};
114 xterm.showCursor = function() {};
115 xterm.clearSelection = function() {};
237e6819 116 xterm.compositionHelper = {
a3a7017f
DI
117 isComposing: false,
118 keydown: {
119 bind: function() {
120 return function() { return true; };
121 }
122 }
237e6819 123 };
00f380a7 124 });
b01165c1 125
126 describe('On Mac OS', function() {
127 beforeEach(function() {
128 xterm.isMac = true;
129 });
130
131 it('should not interfere with the alt key on keyDown', function() {
132 assert.equal(
6663a947 133 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, keyCode: 81 })),
b01165c1 134 true
135 );
136 assert.equal(
6663a947 137 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, keyCode: 192 })),
b01165c1 138 true
139 );
140 });
141
142 it('should interefere with the alt + arrow keys', function() {
143 assert.equal(
6663a947 144 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, keyCode: 37 })),
b01165c1 145 false
146 );
147 assert.equal(
6663a947 148 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, keyCode: 39 })),
b01165c1 149 false
150 );
151 });
152
153 it('should emit key with alt + key on keyPress', function(done) {
154 var keys = ['@', '@', '\\', '\\', '|', '|'];
155
156 xterm.on('keypress', function(key) {
157 if (key) {
158 var index = keys.indexOf(key);
159 assert(index !== -1, "Emitted wrong key: " + key);
160 keys.splice(index, 1);
161 }
162 if (keys.length === 0) done();
163 });
164
6663a947 165 xterm.keyPress(Object.assign({}, evKeyPress, { altKey: true, keyCode: 64 })); // @
b01165c1 166 // Firefox
6663a947
PK
167 xterm.keyPress(Object.assign({}, evKeyPress, { altKey: true, charCode: 64, keyCode: 0 }));
168 xterm.keyPress(Object.assign({}, evKeyPress, { altKey: true, keyCode: 92 })); // \
169 xterm.keyPress(Object.assign({}, evKeyPress, { altKey: true, charCode: 92, keyCode: 0 }));
170 xterm.keyPress(Object.assign({}, evKeyPress, { altKey: true, keyCode: 124 })); // |
171 xterm.keyPress(Object.assign({}, evKeyPress, { altKey: true, charCode: 124, keyCode: 0 }));
b01165c1 172 });
173 });
174
175 describe('On MS Windows', function() {
176 beforeEach(function() {
177 xterm.isMSWindows = true;
178 });
179
180 it('should not interfere with the alt + ctrl key on keyDown', function() {
181 assert.equal(
6663a947 182 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, ctrlKey: true, keyCode: 81 })),
b01165c1 183 true
184 );
185 assert.equal(
6663a947 186 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, ctrlKey: true, keyCode: 192 })),
b01165c1 187 true
188 );
189 });
190
191 it('should interefere with the alt + ctrl + arrow keys', function() {
192 assert.equal(
6663a947 193 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, ctrlKey: true, keyCode: 37 })),
b01165c1 194 false
195 );
196 assert.equal(
6663a947 197 xterm.keyDown(Object.assign({}, evKeyDown, { altKey: true, ctrlKey: true, keyCode: 39 })),
b01165c1 198 false
199 );
200 });
201
202 it('should emit key with alt + ctrl + key on keyPress', function(done) {
203 var keys = ['@', '@', '\\', '\\', '|', '|'];
204
205 xterm.on('keypress', function(key) {
206 if (key) {
207 var index = keys.indexOf(key);
208 assert(index !== -1, "Emitted wrong key: " + key);
209 keys.splice(index, 1);
210 }
211 if (keys.length === 0) done();
212 });
213
214 xterm.keyPress(
6663a947 215 Object.assign({}, evKeyPress, { altKey: true, ctrlKey: true, keyCode: 64 })
b01165c1 216 ); // @
217 xterm.keyPress(
6663a947 218 Object.assign({}, evKeyPress, { altKey: true, ctrlKey: true, charCode: 64, keyCode: 0 })
b01165c1 219 );
220 xterm.keyPress(
6663a947 221 Object.assign({}, evKeyPress, { altKey: true, ctrlKey: true, keyCode: 92 })
b01165c1 222 ); // \
223 xterm.keyPress(
6663a947 224 Object.assign({}, evKeyPress, { altKey: true, ctrlKey: true, charCode: 92, keyCode: 0 })
b01165c1 225 );
226 xterm.keyPress(
6663a947 227 Object.assign({}, evKeyPress, { altKey: true, ctrlKey: true, keyCode: 124 })
b01165c1 228 ); // |
229 xterm.keyPress(
6663a947 230 Object.assign({}, evKeyPress, { altKey: true, ctrlKey: true, charCode: 124, keyCode: 0 })
b01165c1 231 );
232 });
233 });
234 });
c3bc59b5 235
4afa08da 236 describe('unicode - surrogates', function() {
c3bc59b5 237 it('2 characters per cell', function () {
4afa08da
JB
238 var high = '\uD800';
239 for (var i=0xDC00; i<=0xDCFF; ++i) {
240 xterm.write(high + String.fromCharCode(i));
241 var tchar = xterm.lines[0][0];
242 expect(tchar[1]).eql(high + String.fromCharCode(i));
243 expect(tchar[1].length).eql(2);
244 expect(tchar[2]).eql(1);
245 expect(xterm.lines[0][1][1]).eql(' ');
246 xterm.reset();
247 }
c3bc59b5 248 });
4afa08da
JB
249 it('2 characters at last cell', function() {
250 var high = '\uD800';
251 for (var i=0xDC00; i<=0xDCFF; ++i) {
252 xterm.x = xterm.cols - 1;
253 xterm.write(high + String.fromCharCode(i));
254 expect(xterm.lines[0][xterm.x-1][1]).eql(high + String.fromCharCode(i));
255 expect(xterm.lines[0][xterm.x-1][1].length).eql(2);
256 expect(xterm.lines[1][0][1]).eql(' ');
257 xterm.reset();
258 }
c3bc59b5 259 });
4afa08da
JB
260 it('2 characters per cell over line end with autowrap', function() {
261 var high = '\uD800';
262 for (var i=0xDC00; i<=0xDCFF; ++i) {
263 xterm.x = xterm.cols - 1;
264 xterm.wraparoundMode = true;
265 xterm.write('a' + high + String.fromCharCode(i));
266 expect(xterm.lines[0][xterm.cols-1][1]).eql('a');
267 expect(xterm.lines[1][0][1]).eql(high + String.fromCharCode(i));
268 expect(xterm.lines[1][0][1].length).eql(2);
269 expect(xterm.lines[1][1][1]).eql(' ');
270 xterm.reset();
271 }
c3bc59b5 272 });
4afa08da
JB
273 it('2 characters per cell over line end without autowrap', function() {
274 var high = '\uD800';
275 for (var i=0xDC00; i<=0xDCFF; ++i) {
276 xterm.x = xterm.cols - 1;
277 xterm.wraparoundMode = false;
278 xterm.write('a' + high + String.fromCharCode(i));
279 expect(xterm.lines[0][xterm.cols-1][1]).eql(high + String.fromCharCode(i));
280 expect(xterm.lines[0][xterm.cols-1][1].length).eql(2);
281 expect(xterm.lines[1][1][1]).eql(' ');
282 xterm.reset();
283 }
c3bc59b5 284 });
4afa08da
JB
285 it('splitted surrogates', function() {
286 var high = '\uD800';
287 for (var i=0xDC00; i<=0xDCFF; ++i) {
288 xterm.write(high);
289 xterm.write(String.fromCharCode(i));
290 var tchar = xterm.lines[0][0];
291 expect(tchar[1]).eql(high + String.fromCharCode(i));
292 expect(tchar[1].length).eql(2);
293 expect(tchar[2]).eql(1);
294 expect(xterm.lines[0][1][1]).eql(' ');
295 xterm.reset();
296 }
c3bc59b5 297 });
4afa08da
JB
298 });
299
300 describe('unicode - combining characters', function() {
c3bc59b5 301 it('café', function () {
4afa08da
JB
302 xterm.write('cafe\u0301');
303 expect(xterm.lines[0][3][1]).eql('e\u0301');
304 expect(xterm.lines[0][3][1].length).eql(2);
305 expect(xterm.lines[0][3][2]).eql(1);
c3bc59b5 306 });
4afa08da
JB
307 it('café - end of line', function() {
308 xterm.x = xterm.cols - 1 - 3;
309 xterm.write('cafe\u0301');
310 expect(xterm.lines[0][xterm.cols-1][1]).eql('e\u0301');
311 expect(xterm.lines[0][xterm.cols-1][1].length).eql(2);
312 expect(xterm.lines[0][xterm.cols-1][2]).eql(1);
313 expect(xterm.lines[0][1][1]).eql(' ');
314 expect(xterm.lines[0][1][1].length).eql(1);
315 expect(xterm.lines[0][1][2]).eql(1);
c3bc59b5 316 });
4afa08da
JB
317 it('multiple combined é', function() {
318 xterm.wraparoundMode = true;
319 xterm.write(Array(100).join('e\u0301'));
320 for (var i=0; i<xterm.cols; ++i) {
321 var tchar = xterm.lines[0][i];
322 expect(tchar[1]).eql('e\u0301');
323 expect(tchar[1].length).eql(2);
324 expect(tchar[2]).eql(1);
325 }
326 tchar = xterm.lines[1][0];
327 expect(tchar[1]).eql('e\u0301');
328 expect(tchar[1].length).eql(2);
329 expect(tchar[2]).eql(1);
c3bc59b5 330 });
4afa08da
JB
331 it('multiple surrogate with combined', function() {
332 xterm.wraparoundMode = true;
333 xterm.write(Array(100).join('\uD800\uDC00\u0301'));
334 for (var i=0; i<xterm.cols; ++i) {
335 var tchar = xterm.lines[0][i];
336 expect(tchar[1]).eql('\uD800\uDC00\u0301');
337 expect(tchar[1].length).eql(3);
338 expect(tchar[2]).eql(1);
339 }
340 tchar = xterm.lines[1][0];
341 expect(tchar[1]).eql('\uD800\uDC00\u0301');
342 expect(tchar[1].length).eql(3);
343 expect(tchar[2]).eql(1);
c3bc59b5 344 });
4afa08da 345 });
c3bc59b5 346
4afa08da
JB
347 describe('unicode - fullwidth characters', function() {
348 it('cursor movement even', function() {
349 expect(xterm.x).eql(0);
350 xterm.write('¥');
351 expect(xterm.x).eql(2);
c3bc59b5 352 });
4afa08da
JB
353 it('cursor movement odd', function() {
354 xterm.x = 1;
355 expect(xterm.x).eql(1);
356 xterm.write('¥');
357 expect(xterm.x).eql(3);
c3bc59b5 358 });
4afa08da
JB
359 it('line of ¥ even', function() {
360 xterm.wraparoundMode = true;
361 xterm.write(Array(50).join('¥'));
362 for (var i=0; i<xterm.cols; ++i) {
363 var tchar = xterm.lines[0][i];
364 if (i % 2) {
365 expect(tchar[1]).eql('');
366 expect(tchar[1].length).eql(0);
367 expect(tchar[2]).eql(0);
368 } else {
369 expect(tchar[1]).eql('¥');
370 expect(tchar[1].length).eql(1);
371 expect(tchar[2]).eql(2);
c3bc59b5 372 }
4afa08da
JB
373 }
374 tchar = xterm.lines[1][0];
375 expect(tchar[1]).eql('¥');
376 expect(tchar[1].length).eql(1);
377 expect(tchar[2]).eql(2);
c3bc59b5 378 });
4afa08da
JB
379 it('line of ¥ odd', function() {
380 xterm.wraparoundMode = true;
381 xterm.x = 1;
382 xterm.write(Array(50).join('¥'));
383 for (var i=1; i<xterm.cols-1; ++i) {
384 var tchar = xterm.lines[0][i];
385 if (!(i % 2)) {
386 expect(tchar[1]).eql('');
387 expect(tchar[1].length).eql(0);
388 expect(tchar[2]).eql(0);
389 } else {
390 expect(tchar[1]).eql('¥');
391 expect(tchar[1].length).eql(1);
392 expect(tchar[2]).eql(2);
c3bc59b5 393 }
4afa08da
JB
394 }
395 tchar = xterm.lines[0][xterm.cols-1];
396 expect(tchar[1]).eql(' ');
397 expect(tchar[1].length).eql(1);
398 expect(tchar[2]).eql(1);
399 tchar = xterm.lines[1][0];
400 expect(tchar[1]).eql('¥');
401 expect(tchar[1].length).eql(1);
402 expect(tchar[2]).eql(2);
c3bc59b5 403 });
4afa08da
JB
404 it('line of ¥ with combining odd', function() {
405 xterm.wraparoundMode = true;
406 xterm.x = 1;
407 xterm.write(Array(50).join('¥\u0301'));
408 for (var i=1; i<xterm.cols-1; ++i) {
409 var tchar = xterm.lines[0][i];
410 if (!(i % 2)) {
411 expect(tchar[1]).eql('');
412 expect(tchar[1].length).eql(0);
413 expect(tchar[2]).eql(0);
414 } else {
415 expect(tchar[1]).eql('¥\u0301');
416 expect(tchar[1].length).eql(2);
417 expect(tchar[2]).eql(2);
c3bc59b5 418 }
4afa08da
JB
419 }
420 tchar = xterm.lines[0][xterm.cols-1];
421 expect(tchar[1]).eql(' ');
422 expect(tchar[1].length).eql(1);
423 expect(tchar[2]).eql(1);
424 tchar = xterm.lines[1][0];
425 expect(tchar[1]).eql('¥\u0301');
426 expect(tchar[1].length).eql(2);
427 expect(tchar[2]).eql(2);
c3bc59b5 428 });
4afa08da
JB
429 it('line of ¥ with combining even', function() {
430 xterm.wraparoundMode = true;
431 xterm.write(Array(50).join('¥\u0301'));
432 for (var i=0; i<xterm.cols; ++i) {
433 var tchar = xterm.lines[0][i];
434 if (i % 2) {
435 expect(tchar[1]).eql('');
436 expect(tchar[1].length).eql(0);
437 expect(tchar[2]).eql(0);
438 } else {
439 expect(tchar[1]).eql('¥\u0301');
440 expect(tchar[1].length).eql(2);
441 expect(tchar[2]).eql(2);
c3bc59b5 442 }
4afa08da
JB
443 }
444 tchar = xterm.lines[1][0];
445 expect(tchar[1]).eql('¥\u0301');
446 expect(tchar[1].length).eql(2);
447 expect(tchar[2]).eql(2);
c3bc59b5 448 });
4afa08da
JB
449 it('line of surrogate fullwidth with combining odd', function() {
450 xterm.wraparoundMode = true;
451 xterm.x = 1;
452 xterm.write(Array(50).join('\ud843\ude6d\u0301'));
453 for (var i=1; i<xterm.cols-1; ++i) {
454 var tchar = xterm.lines[0][i];
455 if (!(i % 2)) {
456 expect(tchar[1]).eql('');
457 expect(tchar[1].length).eql(0);
458 expect(tchar[2]).eql(0);
459 } else {
460 expect(tchar[1]).eql('\ud843\ude6d\u0301');
461 expect(tchar[1].length).eql(3);
462 expect(tchar[2]).eql(2);
c3bc59b5 463 }
4afa08da
JB
464 }
465 tchar = xterm.lines[0][xterm.cols-1];
466 expect(tchar[1]).eql(' ');
467 expect(tchar[1].length).eql(1);
468 expect(tchar[2]).eql(1);
469 tchar = xterm.lines[1][0];
470 expect(tchar[1]).eql('\ud843\ude6d\u0301');
471 expect(tchar[1].length).eql(3);
472 expect(tchar[2]).eql(2);
c3bc59b5 473 });
4afa08da
JB
474 it('line of surrogate fullwidth with combining even', function() {
475 xterm.wraparoundMode = true;
476 xterm.write(Array(50).join('\ud843\ude6d\u0301'));
477 for (var i=0; i<xterm.cols; ++i) {
478 var tchar = xterm.lines[0][i];
479 if (i % 2) {
480 expect(tchar[1]).eql('');
481 expect(tchar[1].length).eql(0);
482 expect(tchar[2]).eql(0);
483 } else {
484 expect(tchar[1]).eql('\ud843\ude6d\u0301');
485 expect(tchar[1].length).eql(3);
486 expect(tchar[2]).eql(2);
c3bc59b5 487 }
4afa08da
JB
488 }
489 tchar = xterm.lines[1][0];
490 expect(tchar[1]).eql('\ud843\ude6d\u0301');
491 expect(tchar[1].length).eql(3);
492 expect(tchar[2]).eql(2);
c3bc59b5 493 });
4afa08da 494 });
c3bc59b5 495
4afa08da
JB
496 describe('insert mode', function() {
497 it('halfwidth - all', function () {
498 xterm.write(Array(9).join('0123456789').slice(-80));
499 xterm.x = 10;
500 xterm.y = 0;
501 xterm.insertMode = true;
502 xterm.write('abcde');
503 expect(xterm.lines[0].length).eql(xterm.cols);
504 expect(xterm.lines[0][10][1]).eql('a');
505 expect(xterm.lines[0][14][1]).eql('e');
506 expect(xterm.lines[0][15][1]).eql('0');
507 expect(xterm.lines[0][79][1]).eql('4');
508 });
509 it('fullwidth - insert', function() {
510 xterm.write(Array(9).join('0123456789').slice(-80));
511 xterm.x = 10;
512 xterm.y = 0;
513 xterm.insertMode = true;
514 xterm.write('¥¥¥');
515 expect(xterm.lines[0].length).eql(xterm.cols);
516 expect(xterm.lines[0][10][1]).eql('¥');
517 expect(xterm.lines[0][11][1]).eql('');
518 expect(xterm.lines[0][14][1]).eql('¥');
519 expect(xterm.lines[0][15][1]).eql('');
520 expect(xterm.lines[0][79][1]).eql('3');
521 });
522 it('fullwidth - right border', function() {
523 xterm.write(Array(41).join('¥'));
524 xterm.x = 10;
525 xterm.y = 0;
526 xterm.insertMode = true;
527 xterm.write('a');
528 expect(xterm.lines[0].length).eql(xterm.cols);
529 expect(xterm.lines[0][10][1]).eql('a');
530 expect(xterm.lines[0][11][1]).eql('¥');
531 expect(xterm.lines[0][79][1]).eql(' '); // fullwidth char got replaced
532 xterm.write('b');
533 expect(xterm.lines[0].length).eql(xterm.cols);
534 expect(xterm.lines[0][11][1]).eql('b');
535 expect(xterm.lines[0][12][1]).eql('¥');
536 expect(xterm.lines[0][79][1]).eql(''); // empty cell after fullwidth
537 });
538 });
fa093e2b 539});