mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-01 21:57:17 +00:00
handle dwidth characters.
This commit is contained in:
parent
a82ad19110
commit
db46a020a3
@ -2052,6 +2052,15 @@ Element.prototype._wrapContent = function(content, width) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for (i = 0; i < line.length; i++) {
|
||||||
|
// if (isDwidth(line[i])) {
|
||||||
|
// line = line.substring(0, i) + line[i] + '\0' + line.substring(i + 1);
|
||||||
|
// i++;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
line = line.replace(dwidthChars, '$1\0');
|
||||||
|
|
||||||
if (!wrap && line.length > width) {
|
if (!wrap && line.length > width) {
|
||||||
line = line.slice(0, width);
|
line = line.slice(0, width);
|
||||||
}
|
}
|
||||||
@ -2826,6 +2835,10 @@ Element.prototype.render = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ch === '\0') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle newlines.
|
// Handle newlines.
|
||||||
if (ch === '\t') ch = ' ';
|
if (ch === '\t') ch = ' ';
|
||||||
if (ch === '\n') {
|
if (ch === '\n') {
|
||||||
@ -5466,6 +5479,30 @@ function hsort(obj) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dwidthChars = new RegExp('(['
|
||||||
|
+ '\\uff01-\\uffbe'
|
||||||
|
+ '\\uffc2-\\uffc7'
|
||||||
|
+ '\\uffca-\\uffcf'
|
||||||
|
+ '\\uffd2-\\uffd7'
|
||||||
|
+ '\\uffda-\\uffdc'
|
||||||
|
+ '\\uffe0-\\uffe6'
|
||||||
|
+ '\\uffe8-\\uffee'
|
||||||
|
+ '])', 'g');
|
||||||
|
|
||||||
|
function isDwidthR(ch) {
|
||||||
|
return dwidthChars.test(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDwidth(ch) {
|
||||||
|
return (ch >= '\uff01' && ch <= '\uffbe')
|
||||||
|
|| (ch >= '\uffc2' && ch <= '\uffc7')
|
||||||
|
|| (ch >= '\uffca' && ch <= '\uffcf')
|
||||||
|
|| (ch >= '\uffd2' && ch <= '\uffd7')
|
||||||
|
|| (ch >= '\uffda' && ch <= '\uffdc')
|
||||||
|
|| (ch >= '\uffe0' && ch <= '\uffe6')
|
||||||
|
|| (ch >= '\uffe8' && ch <= '\uffee');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose
|
* Expose
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user