Skip to content

Commit

Permalink
Improved fullUnicode support
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Mar 14, 2023
1 parent b6439a2 commit 116cbac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lib/unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ exports.codePointAt = function(str, position) {
if (str == null) {
throw TypeError();
}
var string = String(str);
var string = str;
if ("string" !== typeof str) {
string = String(str);
}
if (string.codePointAt) {
return string.codePointAt(position);
}
Expand Down
19 changes: 14 additions & 5 deletions lib/widgets/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ Element.prototype.parseContent = function(noTags) {
// 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.
content = content.replace(unicode.chars.all, '$1\x03');
// iTerm2 cannot render combining characters properly.
if (this.screen.program.isiTerm2) {
content = content.replace(unicode.chars.combining, '');
}
// iTerm2 cannot render combining characters properly. - not the case anymore!
// see: https://gitlab.com/gnachman/iterm2/-/issues/2639
// if (this.screen.program.isiTerm2) {
// content = content.replace(unicode.chars.combining, '');
// }
} else {
// no double-width: replace them with question-marks.
content = content.replace(unicode.chars.all, '??');
Expand Down Expand Up @@ -640,7 +641,15 @@ main:
}

// If the string is apparently too long, wrap it.
while (line.length > width) {
const fullUnicode = this.screen.fullUnicode
const lineLen = function() {
if (fullUnicode) {
return unicode.strWidth(line);
} else {
return line.length;
}
}
while (wrap && lineLen() > width) {
// Measure the real width of the string.
for (i = 0, total = 0; i < line.length; i++) {
while (line[i] === '\x1b') {
Expand Down

0 comments on commit 116cbac

Please sign in to comment.