From bcc5120befd74ff583333f78a75729a87d13515c Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 6 Jul 2019 11:57:13 -0300 Subject: Support hiding the left pane Testing this out in the telnet client. Also some tweaks to tabber keybinding behavior. --- telnet-server.js | 1 + ui.js | 53 ++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/telnet-server.js b/telnet-server.js index 479bd2b..d12e649 100644 --- a/telnet-server.js +++ b/telnet-server.js @@ -27,6 +27,7 @@ class TelnetServer { writable: socket, interfacer, appConfig: { + showLeftPane: false, stopPlayingUponQuit: false, menubarColor: 2 } diff --git a/ui.js b/ui.js index 65f62cf..21b5844 100644 --- a/ui.js +++ b/ui.js @@ -143,6 +143,7 @@ class AppElement extends FocusElement { this.attachListeners() this.config = Object.assign({ + showLeftPane: true, menubarColor: 4, // blue stopPlayingUponQuit: true }, config) @@ -166,6 +167,10 @@ class AppElement extends FocusElement { this.paneRight = new Pane() this.addChild(this.paneRight) + if (!this.config.showLeftPane) { + this.paneLeft.visible = false + } + this.tabber = new Tabber() this.paneLeft.addChild(this.tabber) @@ -191,7 +196,7 @@ class AppElement extends FocusElement { this.queueListingElement.on('shuffle', () => this.shuffleQueue()) this.queueListingElement.on('clear', () => this.clearQueue()) this.queueListingElement.on('select main listing', - () => this.root.select(this.tabber)) + () => this.selected()) this.playbackPane = new Pane() this.addChild(this.playbackPane) @@ -333,7 +338,15 @@ class AppElement extends FocusElement { } selected() { - this.root.select(this.tabber) + if (this.paneLeft.visible) { + this.root.select(this.tabber) + } else { + if (this.queueListingElement.selectable) { + this.root.select(this.queueListingElement) + } else { + this.menubar.select() + } + } } newGrouplikeListing() { @@ -441,6 +454,10 @@ class AppElement extends FocusElement { } reveal(item) { + if (!this.paneLeft.visible) { + return + } + const tabberListing = this.tabber.currentElement this.root.select(tabberListing) if (isGroup(item)) { @@ -623,14 +640,22 @@ class AppElement extends FocusElement { this.menubar.fixLayout() - this.paneLeft.w = Math.max(Math.floor(0.8 * this.contentW), this.contentW - 80) - this.paneLeft.h = this.contentH - 6 - this.paneLeft.y = 1 - this.paneRight.x = this.paneLeft.right - this.paneRight.w = this.contentW - this.paneLeft.right - this.paneRight.h = this.paneLeft.h + const mainHeight = this.contentH - 6 + + if (this.paneLeft.visible) { + this.paneLeft.w = Math.max(Math.floor(0.8 * this.contentW), this.contentW - 80) + this.paneLeft.h = mainHeight + this.paneLeft.y = 1 + this.paneRight.x = this.paneLeft.right + this.paneRight.w = this.contentW - this.paneLeft.right + } else { + this.paneRight.x = 0 + this.paneRight.w = this.contentW + } + this.paneRight.y = 1 - this.playbackPane.y = this.paneLeft.bottom + this.paneRight.h = mainHeight + this.playbackPane.y = mainHeight + 1 this.playbackPane.w = this.contentW this.playbackPane.h = this.contentH - this.playbackPane.y @@ -682,7 +707,7 @@ class AppElement extends FocusElement { this.backend.playPrevious(this.backend.playingTrack, true) } else if (input.isSkipAhead(keyBuf)) { this.backend.playNext(this.backend.playingTrack, true) - } else if (input.isFocusTabber(keyBuf) && this.tabber.selectable) { + } else if (input.isFocusTabber(keyBuf) && this.paneLeft.visible && this.tabber.selectable) { this.root.select(this.tabber) } else if (input.isFocusQueue(keyBuf) && this.queueListingElement.selectable) { this.root.select(this.queueListingElement) @@ -698,10 +723,12 @@ class AppElement extends FocusElement { this.newEmptyTab() } else if (keyBuf.equals(Buffer.from([15]))) { // ctrl-O this.openPlaylistDialog.open() - } else if (keyBuf.equals(Buffer.from([20]))) { // ctrl-T + } else if (this.tabber.isSelected && keyBuf.equals(Buffer.from([20]))) { // ctrl-T this.cloneCurrentTab() - } else if (keyBuf.equals(Buffer.from([23]))) { // ctrl-W - this.closeCurrentTab() + } else if (this.tabber.isSelected && keyBuf.equals(Buffer.from([23]))) { // ctrl-W + if (this.tabber.tabberElements.length > 1) { + this.closeCurrentTab() + } } else if (telc.isCharacter(keyBuf, 'u')) { this.undoManager.undoLastAction() } else if (telc.isCharacter(keyBuf, 'U')) { -- cgit 1.3.0-6-gf8a5