« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/ui.js b/ui.js
index c86c8ad..6acebc7 100644
--- a/ui.js
+++ b/ui.js
@@ -1249,7 +1249,8 @@ class BasicGrouplikeItemElement extends Button {
 
         for (const char of characters) {
           if (heckingWatchOut) {
-            if (ansi.measureColumns(text + char) <= this.w - this.x) {
+            // 3 = width of status line, basically
+            if (ansi.measureColumns(text + char) + 3 <= this.w - this.x) {
               text += char
             } else {
               done = true
@@ -1262,18 +1263,15 @@ class BasicGrouplikeItemElement extends Button {
       }
     }
 
-    this.drawX = this.x
-    this.writeStatus(writable)
-
     // This is the part where we want to be careful to not go over the width
     // limit..
     heckingWatchOut = true
     writable.write(this.text)
-    this.drawX += ansi.measureColumns(this.text)
     heckingWatchOut = false
 
-    writable.write(' '.repeat(Math.max(0, this.w - this.drawX)))
-
+    const width = ansi.measureColumns(this.text)
+    // again, 3 = width of status bar
+    writable.write(' '.repeat(Math.max(0, this.w - width - 3)))
     writable.write(ansi.resetAttributes())
 
     this.drawText = text
@@ -1294,6 +1292,7 @@ class BasicGrouplikeItemElement extends Button {
     }
 
     writable.write(ansi.moveCursor(this.absTop, this.absLeft))
+    this.writeStatus(writable)
     writable.write(this.drawText)
   }