Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,13 +1225,13 @@ Terminal.prototype.refresh = function(start, end) {

attr = this.defAttr;
i = 0;

for (; i < width; i++) {
var widthd = width;
for (; i < widthd; i++) {
data = line[i][0];
ch = line[i][1];

if (i === x) data = -1;

if (ch.charCodeAt()>=127){widthd=widthd-0.7}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this should not be every character over 127 - there are many characters beyond that which should still be displayed as single width, like £ (163), or ø (248). Those are just examples, there are many, many more, and working out which ones need width adjustment is tricky.

I'm also not sure where the 0.7 comes from. This may work for the wide characters of one particular font, but I wouldn't rely on it working in general.

There is already a mechanism for dealing with wide characters, which works by allowing them twice the normal space in the grid. However, it doesn't know about all the wide characters, as described in #66.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

127 and 0.7 also my empirical data, so maybe just fit for me

thanks for your work!

if (data !== attr) {
if (attr !== this.defAttr) {
out += '</span>';
Expand Down Expand Up @@ -1439,7 +1439,7 @@ Terminal.prototype.write = function(data) {
}

// this.log(JSON.stringify(data.replace(/\x1b/g, '^[')));

this.colss = this.cols;
for (; i < l; i++) {
ch = data[i];
switch (this.state) {
Expand Down Expand Up @@ -1510,10 +1510,11 @@ Terminal.prototype.write = function(data) {
if (this.charset && this.charset[ch]) {
ch = this.charset[ch];
}

if (this.x >= this.cols) {
if (ch.charCodeAt()>=127){this.colss=this.colss-0.7}
if (this.x >= this.colss) {
this.x = 0;
this.y++;
this.colss=this.cols;
if (this.y > this.scrollBottom) {
this.y--;
this.scroll();
Expand All @@ -1526,7 +1527,7 @@ Terminal.prototype.write = function(data) {

if (isWide(ch)) {
j = this.y + this.ybase;
if (this.cols < 2 || this.x >= this.cols) {
if (this.colss < 2 || this.x >= this.colss) {
this.lines[j][this.x - 1] = [this.curAttr, ' '];
break;
}
Expand Down