diff options
author | Florrie <towerofnix@gmail.com> | 2018-12-05 16:40:46 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-12-05 16:40:46 -0400 |
commit | d59d12196ad00a51d76e0ef4b6808ec2978f7649 (patch) | |
tree | f2169f71edce85ce69d752024f2f60e6931dfe44 | |
parent | bc5199c288bb93451927af0cc31a98cf0a25f843 (diff) |
Add utility measureColumns function to ansi.js
This way layouts can properly support wide characters.
-rw-r--r-- | util/ansi.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/util/ansi.js b/util/ansi.js index f0d7bf7..f976c12 100644 --- a/util/ansi.js +++ b/util/ansi.js @@ -113,6 +113,12 @@ const ansi = { return `${ESC}[6n` }, + measureColumns(text) { + // Returns the number of columns the given text takes. + + return wcwidth(text) + }, + isANSICommand(buffer, code = null) { return ( buffer[0] === 0x1b && buffer[1] === 0x5b && |