diff --git a/lib/unicode.js b/lib/unicode.js index 0238e26..04f77ef 100644 --- a/lib/unicode.js +++ b/lib/unicode.js @@ -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]) { diff --git a/lib/widget.js b/lib/widget.js index 834d395..a7d879d 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -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 =