From d59d12196ad00a51d76e0ef4b6808ec2978f7649 Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 5 Dec 2018 16:40:46 -0400 Subject: Add utility measureColumns function to ansi.js This way layouts can properly support wide characters. --- util/ansi.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util/ansi.js') 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 && -- cgit 1.3.0-6-gf8a5