« 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.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/ui.js b/ui.js
index 8d912a2..4ad09e9 100644
--- a/ui.js
+++ b/ui.js
@@ -109,6 +109,10 @@ class AppElement extends FocusElement {
     this.setupDialog(this.alertDialog)
   }
 
+  selected() {
+    this.root.select(this.form)
+  }
+
   async handlePlaylistSource(source) {
     this.openPlaylistDialog.close()
     this.alertDialog.showMessage('Opening playlist...', false)
@@ -547,7 +551,7 @@ class GrouplikeListingElement extends FocusElement {
     this.pathElement.w = this.contentW
   }
 
-  focused() {
+  selected() {
     this.root.select(this.form)
   }
 
@@ -555,10 +559,6 @@ class GrouplikeListingElement extends FocusElement {
     return this.form.selectable
   }
 
-  get isSelected() {
-    return this.form.isSelected
-  }
-
   keyPressed(keyBuf) {
     if (telc.isBackspace(keyBuf)) {
       this.loadParentGrouplike()
@@ -669,11 +669,8 @@ class GrouplikeListingForm extends ListScrollForm {
     return Math.min(this.inputs.length, 1)
   }
 
-  get isSelected() {
-    return this.root.selected && this.root.selected.directAncestors.includes(this)
-  }
-
   selectAndShow(item) {
+    // TODO: Make sure this is still working.
     const index = this.inputs.findIndex(inp => inp.item === item)
     if (index >= 0) {
       this.curIndex = index
@@ -699,7 +696,7 @@ class GrouplikeItemElement extends Button {
   }
 
   drawTo(writable) {
-    if (this.isFocused) {
+    if (this.isSelected) {
       writable.write(ansi.invert())
     }
 
@@ -809,7 +806,7 @@ class PathItemElement extends FocusElement {
     this.addChild(this.arrowLabel)
   }
 
-  focused() {
+  selected() {
     this.root.select(this.button)
   }
 
@@ -957,7 +954,7 @@ class OpenPlaylistDialog extends Dialog {
     this.button.y = 1
   }
 
-  focused() {
+  selected() {
     this.root.select(this.form)
   }
 }
@@ -978,7 +975,7 @@ class AlertDialog extends Dialog {
     this.pane.addChild(this.button)
   }
 
-  focused() {
+  selected() {
     this.root.select(this.button)
   }