From bef63acfad7a793f9bd72cb3985c57b60bf58b77 Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 4 Jul 2018 22:51:43 -0300 Subject: focused -> selected --- index.js | 2 +- tui-lib | 2 +- ui.js | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 694a384..c0e2932 100755 --- a/index.js +++ b/index.js @@ -69,7 +69,7 @@ async function main() { appElement.grouplikeListingElement.loadGrouplike(grouplike) - root.select(appElement.form) + root.select(appElement) if (process.argv[2]) { appElement.handlePlaylistSource(process.argv[2]) diff --git a/tui-lib b/tui-lib index 1076bd5..eebff4f 160000 --- a/tui-lib +++ b/tui-lib @@ -1 +1 @@ -Subproject commit 1076bd5e65658a0e846a7892cee787ade7660bb2 +Subproject commit eebff4fbbac489f96954f05d6d0d838c62a8e6c7 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) } -- cgit 1.3.0-6-gf8a5