« get me outta code hell

Fix the Act of Evil related to real-cursor visibility - 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
diff options
context:
space:
mode:
authorliam4 <towerofnix@gmail.com>2017-07-03 21:18:25 -0300
committerliam4 <towerofnix@gmail.com>2017-07-03 21:18:25 -0300
commit3f1ff3586fb5db8ab99fdab6e5c5a476cc129cba (patch)
tree1f86d7a9b7cd0dee47efc8dd6b9f644a9eda3bd7 /ui
parentb087c428ba492715626a7875185f9ba18fb30b3e (diff)
Fix the Act of Evil related to real-cursor visibility
Diffstat (limited to 'ui')
-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() {