improve charWidth and strWidth.
This commit is contained in:
parent
4ce0df57da
commit
23567a75ab
|
@ -118,6 +118,21 @@ exports.charWidth = function(str, i) {
|
|||
// nul
|
||||
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
|
||||
// is ucs combining or C0/C1 control character
|
||||
if (exports.combining[point]) {
|
||||
|
|
|
@ -5972,9 +5972,9 @@ Textarea.prototype._updateCursor = function(get) {
|
|||
};
|
||||
|
||||
Textarea.prototype._strWidth = function(str) {
|
||||
if (!this.screen.fullUnicode) return str.length;
|
||||
str = str.replace(/\x03/g, '');
|
||||
return unicode.strWidth(str, 0);
|
||||
return this.screen.fullUnicode
|
||||
? unicode.strWidth(str)
|
||||
: str.length;
|
||||
};
|
||||
|
||||
Textarea.prototype.input =
|
||||
|
|
Loading…
Reference in New Issue