Gottox / terminal.js

Javascript terminal emulator library that aims to be xterm compliant and is supposed to work in browsers and node.js.
http://terminal.js.org
MIT License
593 stars 69 forks source link

support double-width character #119

Closed kevinptt0323 closed 7 years ago

kevinptt0323 commented 7 years ago

It will be incorrect if there is double-width characters.

it("double width characters", function() {
  var t = newTermState();
  t.write("ab");
  t.mvCursor(-2,0);
  t.write("\u4e00"); // '一' (chinese)
  expect(t.toString()).to.be("\u4e00"); // expect error
});

Maybe you can use wcwidth or string-width to determine the length of string.