From c732ebe5b6736d76439093b6bffff6e5f198a0c9 Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 23 Dec 2018 00:54:50 -0400 Subject: Update tui-lib --- tui-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tui-lib b/tui-lib index d8331b9..0c38fb4 160000 --- a/tui-lib +++ b/tui-lib @@ -1 +1 @@ -Subproject commit d8331b98aad2e29b23e88901049fc3c91489a2c7 +Subproject commit 0c38fb468621b3860fc9c7deb12ae464c57996e8 -- cgit 1.3.0-6-gf8a5 From e9f59f4abf374f29e36ac2037af57270280f80ac Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 23 Dec 2018 00:55:50 -0400 Subject: Fill in package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b3855ac..dae7b6b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "music-ui", - "version": "1.0.0", - "description": "", + "name": "mtui", + "version": "0.0.1", + "description": "Music Text User Interface - user-friendly command line music player", "main": "index.js", "bin": { "mtui": "./index.js" -- cgit 1.3.0-6-gf8a5 From 5ee9b350590626ffdef759409dd38ad6f0ab599b Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 23 Dec 2018 01:03:21 -0400 Subject: Mouse support in tabber elements Click to switch tab, scroll over the tab list to quickly switch to the previous or next tab. --- ui.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ui.js b/ui.js index f5880df..20e59e8 100644 --- a/ui.js +++ b/ui.js @@ -1733,6 +1733,10 @@ class Tabber extends FocusElement { this.listElement = new TabberList(this) this.addChild(this.listElement) + + this.listElement.on('selected', item => this.selectTab(item)) + this.listElement.on('next tab', () => this.nextTab()) + this.listElement.on('previous tab', () => this.previousTab()) } fixLayout() { @@ -1858,6 +1862,7 @@ class TabberList extends ListScrollForm { const element = new TabberListItem(item, this.tabber) this.addInput(element) element.fixLayout() + element.on('selected', () => this.emit('selected', item)) } this.scrollToEnd() @@ -1887,6 +1892,16 @@ class TabberList extends ListScrollForm { } } + clicked(button) { + if (button === 'scroll-up') { + this.emit('previous tab') + return false + } else if (button === 'scroll-down') { + this.emit('next tab') + return false + } + } + // TODO: Be less hacky about these! Right now the tabber list is totally not // interactive. get curIndex() { return this.tabber.currentElementIndex } @@ -1903,6 +1918,7 @@ class TabberListItem extends FocusElement { fixLayout() { this.w = ansi.measureColumns(this.text) + 3 + this.h = 1 } drawTo(writable) { @@ -1917,6 +1933,13 @@ class TabberListItem extends FocusElement { } } + clicked(button) { + if (button === 'left') { + this.emit('selected') + return false + } + } + get text() { return this.tab.tabberLabel || 'a(n) ' + this.tab.constructor.name } -- cgit 1.3.0-6-gf8a5