« get me outta code hell

Set the ANSI compressor on OVERLOAD (underload?) - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/util/Flushable.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-12-10 01:19:52 -0400
committerFlorrie <towerofnix@gmail.com>2017-12-10 01:19:52 -0400
commitd6495a9cfddb65fb9b3cb09771ee0bef88d5d9f7 (patch)
tree8f70682074384e1a8927fc51334049fe1dcc13b4 /util/Flushable.js
parent3334442bbc7520bf091ed37e28a1898685691582 (diff)
Set the ANSI compressor on OVERLOAD (underload?)
Diffstat (limited to 'util/Flushable.js')
-rw-r--r--util/Flushable.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/util/Flushable.js b/util/Flushable.js
index 2248fec..78bf5c5 100644
--- a/util/Flushable.js
+++ b/util/Flushable.js
@@ -86,14 +86,21 @@ module.exports = class Flushable {
 
   compress(toWrite) {
     // TODO: customize screen size
-    let screen = ansi.interpret(toWrite, this.screenLines, this.screenCols)
+    let { newChars, lastChar, screen } = ansi.interpret(
+      toWrite, this.screenLines, this.screenCols,
+      this.lastFrameChars, this.lastFrameLastChar
+    )
+
+    this.lastFrameChars = newChars
+    this.lastFrameLastChar = lastChar
 
     if (this.shouldShowCompressionStatistics) {
       const pcSaved = Math.round(100 - (100 / toWrite.length * screen.length))
       screen += (
-        '\x1b[1A (ANSI-interpret: ' +
-        `${toWrite.length} -> ${screen.length} ${pcSaved}% saved)`
+        '\x1b[H\x1b[0m(ANSI-interpret: ' +
+        `${toWrite.length} -> ${screen.length} ${pcSaved}% saved)  `
       )
+      this.lastFrameLastChar.attributes = []
     }
 
     return screen