fix surrogate singles. stop using bad surrogate double for testing.
see 2eb57cc725
This commit is contained in:
parent
582831e5bc
commit
cb9ffee1e3
|
@ -1209,25 +1209,23 @@ Screen.prototype.draw = function(start, end) {
|
||||||
// If this is a surrogate pair double-width char, we can ignore it
|
// If this is a surrogate pair double-width char, we can ignore it
|
||||||
// because parseContent already counted it as length=2.
|
// because parseContent already counted it as length=2.
|
||||||
point = unicode.codePointAt(line[x][1], 0);
|
point = unicode.codePointAt(line[x][1], 0);
|
||||||
if (point <= 0x00ffff) {
|
cwid = unicode.charWidth(point);
|
||||||
cwid = unicode.charWidth(point);
|
if (cwid === 2) {
|
||||||
if (cwid === 2) {
|
// Might also need: `line[x + 1][0] !== line[x][0]`
|
||||||
// Might also need: `line[x + 1][0] !== line[x][0]`
|
// for borderless boxes?
|
||||||
// for borderless boxes?
|
if (x === line.length - 1 || angles[line[x + 1][1]]) {
|
||||||
if (x === line.length - 1 || angles[line[x + 1][1]]) {
|
// If we're at the end, we don't have enough space for a
|
||||||
// If we're at the end, we don't have enough space for a
|
// double-width. Overwrite it with a space and ignore.
|
||||||
// double-width. Overwrite it with a space and ignore.
|
ch = ' ';
|
||||||
ch = ' ';
|
o[x][1] = '\0';
|
||||||
o[x][1] = '\0';
|
} else {
|
||||||
} else {
|
// ALWAYS refresh double-width chars because this special cursor
|
||||||
// ALWAYS refresh double-width chars because this special cursor
|
// behavior is needed. There may be a more efficient way of doing
|
||||||
// behavior is needed. There may be a more efficient way of doing
|
// this. See above.
|
||||||
// this. See above.
|
o[x][1] = '\0';
|
||||||
o[x][1] = '\0';
|
// Eat the next character by moving forward and marking as a
|
||||||
// Eat the next character by moving forward and marking as a
|
// space (which it is).
|
||||||
// space (which it is).
|
o[++x][1] = '\0';
|
||||||
o[++x][1] = '\0';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2079,14 +2077,12 @@ Screen.prototype.screenshot = function(xi, xl, yi, yl, term) {
|
||||||
|
|
||||||
if (this.fullUnicode) {
|
if (this.fullUnicode) {
|
||||||
point = unicode.codePointAt(line[x][1], 0);
|
point = unicode.codePointAt(line[x][1], 0);
|
||||||
if (point <= 0x00ffff) {
|
cwid = unicode.charWidth(point);
|
||||||
cwid = unicode.charWidth(point);
|
if (cwid === 2) {
|
||||||
if (cwid === 2) {
|
if (x === xl - 1) {
|
||||||
if (x === xl - 1) {
|
ch = ' ';
|
||||||
ch = ' ';
|
} else {
|
||||||
} else {
|
x++;
|
||||||
x++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2432,12 +2428,9 @@ Element.prototype.parseContent = function(noTags) {
|
||||||
if (this.screen.fullUnicode) {
|
if (this.screen.fullUnicode) {
|
||||||
// double-width chars will eat the next char after render. create a
|
// double-width chars will eat the next char after render. create a
|
||||||
// blank character after it so it doesn't eat the real next char.
|
// blank character after it so it doesn't eat the real next char.
|
||||||
content = content.replace(unicode.chars.wide, '$1\x03');
|
content = content.replace(unicode.chars.all, '$1\x03');
|
||||||
// VTE cannot display double-width chars that are also
|
// VTE cannot display double-width chars that are also
|
||||||
// surrogate pairs: It miscalculates the width of the chars.
|
// surrogate pairs: It miscalculates the width of the chars.
|
||||||
if (this.screen.program.isVTE) {
|
|
||||||
content = content.replace(unicode.chars.swide, '??');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// no double-width: replace them with question-marks.
|
// no double-width: replace them with question-marks.
|
||||||
content = content.replace(unicode.chars.all, '??');
|
content = content.replace(unicode.chars.all, '??');
|
||||||
|
@ -2744,14 +2737,14 @@ main:
|
||||||
j--;
|
j--;
|
||||||
if (line[j] === ' '
|
if (line[j] === ' '
|
||||||
|| line[j] === '\x03'
|
|| line[j] === '\x03'
|
||||||
|| unicode.isSurrogate(line, j - 1)
|
|| (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03')
|
||||||
|| unicode.combining[line[j]]) {
|
|| unicode.combining[line[j]]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line[j] === ' '
|
if (line[j] === ' '
|
||||||
|| line[j] === '\x03'
|
|| line[j] === '\x03'
|
||||||
|| unicode.isSurrogate(line, j - 1)
|
|| (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03')
|
||||||
|| unicode.combining[line[j]]) {
|
|| unicode.combining[line[j]]) {
|
||||||
i = j + 1;
|
i = j + 1;
|
||||||
}
|
}
|
||||||
|
@ -2796,31 +2789,6 @@ main:
|
||||||
: current;
|
: current;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Find all surrogate pairs and compensate for the lack of width
|
|
||||||
// on the line by padding with trailing spaces:
|
|
||||||
if (this.screen.fullUnicode) {
|
|
||||||
for (var i = 0; i < out.length; i++) {
|
|
||||||
// NOTE: Happens at 54 cols with all chars enabled in test.
|
|
||||||
// Check to see if surrogates got split on end and beginning of 2 lines.
|
|
||||||
if (/[\ud800-\udbff]$/.exec(out[i])
|
|
||||||
&& /^[\udc00-\udfff]/.exec(out[i + 1])) {
|
|
||||||
out[i] = out[i] + out[i + 1][0];
|
|
||||||
out[i + 1] = out[i + 1].substring(1) + ' ';
|
|
||||||
}
|
|
||||||
// Pad the end of the lines if the surrogate is not a double-width char.
|
|
||||||
// var surrogates = out[i].length - punycode.ucs2.decode(out[i]).length;
|
|
||||||
var surrogates = out[i].match(unicode.chars.surrogate);
|
|
||||||
if (surrogates && surrogates.length) {
|
|
||||||
for (var j = 0; j < surrogates.length; j++) {
|
|
||||||
var cwid = unicode.charWidth(surrogates[j], 0);
|
|
||||||
if (cwid === 1) {
|
|
||||||
out[i] += ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,15 @@ var DOUBLE = DU + JUAN;
|
||||||
|
|
||||||
// var SURROGATE_DOUBLE = '𰀀';
|
// var SURROGATE_DOUBLE = '𰀀';
|
||||||
// var SURROGATE_DOUBLE = String.fromCharCode(0xD880, 0xDC00);
|
// var SURROGATE_DOUBLE = String.fromCharCode(0xD880, 0xDC00);
|
||||||
var SURROGATE_DOUBLE = unicode.fromCodePoint(0x30000);
|
// var SURROGATE_DOUBLE = unicode.fromCodePoint(0x30000);
|
||||||
|
|
||||||
// var SURROGATE_DOUBLE_OTHER = '🉐';
|
// var SURROGATE_DOUBLE = '𠀀';
|
||||||
// var SURROGATE_DOUBLE_OTHER = String.fromCharCode(0xD83C, 0xDE50);
|
// var SURROGATE_DOUBLE = String.fromCharCode(0xd840, 0xdc00);
|
||||||
var SURROGATE_DOUBLE_OTHER = unicode.fromCodePoint(0x1F250);
|
var SURROGATE_DOUBLE = unicode.fromCodePoint(0x20000);
|
||||||
|
|
||||||
|
// var SURROGATE_DOUBLE = '🉐';
|
||||||
|
// var SURROGATE_DOUBLE = String.fromCharCode(0xD83C, 0xDE50);
|
||||||
|
// var SURROGATE_DOUBLE = unicode.fromCodePoint(0x1F250);
|
||||||
|
|
||||||
// var SURROGATE_SINGLE = '𝌆';
|
// var SURROGATE_SINGLE = '𝌆';
|
||||||
// var SURROGATE_SINGLE = String.fromCharCode(0xD834, 0xDF06);
|
// var SURROGATE_SINGLE = String.fromCharCode(0xD834, 0xDF06);
|
||||||
|
|
Loading…
Reference in New Issue