« get me outta code hell

Merge branch 'master' into web-mtui - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-12-23 01:05:09 -0400
committerFlorrie <towerofnix@gmail.com>2018-12-23 01:05:09 -0400
commit386e1054e712fd5f970b0b7c31716577c4bb6366 (patch)
treeb9ed1d95a306b145d9691f4036521ef5c616df2b
parentecb1890db2c0f85cc033753e31ab8804de55133c (diff)
parent5ee9b350590626ffdef759409dd38ad6f0ab599b (diff)
Merge branch 'master' into web-mtui web-mtui
-rw-r--r--package.json6
-rw-r--r--ui.js23
2 files changed, 26 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"
diff --git a/ui.js b/ui.js
index 69fc7f1..fcaba1e 100644
--- a/ui.js
+++ b/ui.js
@@ -1722,6 +1722,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() {
@@ -1847,6 +1851,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()
@@ -1876,6 +1881,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 }
@@ -1892,6 +1907,7 @@ class TabberListItem extends FocusElement {
 
   fixLayout() {
     this.w = ansi.measureColumns(this.text) + 3
+    this.h = 1
   }
 
   drawTo(writable) {
@@ -1906,6 +1922,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
   }