improve charWidth and strWidth.
This commit is contained in:
parent
4ce0df57da
commit
23567a75ab
|
@ -118,6 +118,21 @@ exports.charWidth = function(str, i) {
|
||||||
// nul
|
// nul
|
||||||
if (point === 0) return 0;
|
if (point === 0) return 0;
|
||||||
|
|
||||||
|
// tab
|
||||||
|
if (point === 0x09) {
|
||||||
|
if (!exports.blessed) {
|
||||||
|
exports.blessed = require('../');
|
||||||
|
}
|
||||||
|
return exports.blessed.screen.global
|
||||||
|
? exports.blessed.screen.global.tabc.length
|
||||||
|
: 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8-bit control characters (2-width according to unicode??)
|
||||||
|
if (point < 32 || (point >= 0x7f && point < 0xa0)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// search table of non-spacing characters
|
// search table of non-spacing characters
|
||||||
// is ucs combining or C0/C1 control character
|
// is ucs combining or C0/C1 control character
|
||||||
if (exports.combining[point]) {
|
if (exports.combining[point]) {
|
||||||
|
|
|
@ -5972,9 +5972,9 @@ Textarea.prototype._updateCursor = function(get) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Textarea.prototype._strWidth = function(str) {
|
Textarea.prototype._strWidth = function(str) {
|
||||||
if (!this.screen.fullUnicode) return str.length;
|
return this.screen.fullUnicode
|
||||||
str = str.replace(/\x03/g, '');
|
? unicode.strWidth(str)
|
||||||
return unicode.strWidth(str, 0);
|
: str.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
Textarea.prototype.input =
|
Textarea.prototype.input =
|
||||||
|
|
Loading…
Reference in New Issue