« get me outta code hell

tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui/Root.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/Root.js')
-rw-r--r--ui/Root.js28
1 files changed, 18 insertions, 10 deletions
diff --git a/ui/Root.js b/ui/Root.js
index fc494a7..22c2c97 100644
--- a/ui/Root.js
+++ b/ui/Root.js
@@ -49,17 +49,25 @@ module.exports = class Root extends DisplayElement {
   didRenderTo(writable) {
     // Render the cursor, based on the cursorX and cursorY of the currently
     // selected element.
-    if (
-      this.selected && this.selected.cursorVisible &&
-      (Date.now() - this.cursorBlinkOffset) % 1000 < 500
-    ) {
-      writable.write(ansi.moveCursor(
-        this.selected.absCursorY, this.selected.absCursorX))
-      writable.write(ansi.invert())
-      writable.write('I')
-      writable.write(ansi.resetAttributes())
+    if (this.selected && this.selected.cursorVisible) {
+      if ((Date.now() - this.cursorBlinkOffset) % 1000 < 500) {
+        writable.write(
+          ansi.moveCursor(this.selected.absCursorY, this.selected.absCursorX)
+        )
+        writable.write(ansi.invert())
+        writable.write('I')
+        writable.write(ansi.resetAttributes())
+      }
+
+      writable.write(ansi.showCursor())
+      writable.write(
+        ansi.moveCursor(this.selected.absCursorY, this.selected.absCursorX)
+      )
+    } else {
+      writable.write(ansi.hideCursor())
     }
-    writable.write(ansi.hideCursor())
+
+    if (this.selected && this.selected.cursorVisible) {}
   }
 
   cursorMoved() {