From 596b0241bc1b231428f9eae4cea8a10884e8bb19 Mon Sep 17 00:00:00 2001 From: Matthew Slight Date: Sat, 13 Jan 2018 13:09:57 +0400 Subject: [PATCH 1/3] adds ability to have Zen hide the right and bottom panels, and provides toggle options in Zen config for users --- lib/zen.coffee | 70 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/lib/zen.coffee b/lib/zen.coffee index ae2c42c..2293211 100644 --- a/lib/zen.coffee +++ b/lib/zen.coffee @@ -28,16 +28,26 @@ module.exports = type: 'boolean' default: false order: 5 + bottomPanel: + description: 'Enables / Disables the bottom pane when Zen is active.' + type: 'boolean' + default: true + order: 7 + rightPanel: + description: 'Enables / Disables the right pane when Zen is active.' + type: 'boolean' + default: true + order: 7 width: type: 'integer' default: atom.config.get 'editor.preferredLineLength' - order: 6 + order: 8 tabs: description: 'Determines the tab style used while Zen is active.' type: 'string' default: 'hidden' enum: ['hidden', 'single', 'multiple'] - order: 7 + order: 9 showWordCount: description: 'Show the word-count if you have the package installed.' type: 'string' @@ -47,7 +57,7 @@ module.exports = 'Left', 'Right' ] - order: 8 + order: 10 activate: (state) -> atom.commands.add 'atom-workspace', 'zen:toggle', => @toggle() @@ -59,18 +69,20 @@ module.exports = atom.notifications.addInfo 'Zen cannot be achieved in this view.' return - body = document.querySelector('body') - editor = atom.workspace.getActiveTextEditor() + body = document.querySelector('body') + editor = atom.workspace.getActiveTextEditor() editorElm = atom.workspace.getActiveTextEditor().element # should really check current fullsceen state fullscreen = atom.config.get 'Zen.fullscreen' - width = atom.config.get 'Zen.width' - softWrap = atom.config.get 'Zen.softWrap' - minimap = atom.config.get 'Zen.minimap' + width = atom.config.get 'Zen.width' + softWrap = atom.config.get 'Zen.softWrap' + minimap = atom.config.get 'Zen.minimap' - # Left panel needed for hide/restore - panel = atom.workspace.getLeftDock() + # Panels needed for hide/restore + panelLeft = atom.workspace.getLeftDock() + panelRight = atom.workspace.getRightDock() + panelBottom = atom.workspace.getBottomDock() if body.getAttribute('data-zen') isnt 'true' @@ -145,7 +157,7 @@ module.exports = # Hide TreeView if $('.nuclide-file-tree').length - if panel.isVisible() + if panelLeft.isVisible() atom.commands.dispatch( atom.views.getView(atom.workspace), 'nuclide-file-tree:toggle' @@ -166,6 +178,25 @@ module.exports = ) @restoreMinimap = true + # Hide Right Dock + if atom.config.get 'Zen.rightPanel' + if panelRight.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-right-dock' + ) + @restoreRightDock = true + + # Hide Bottom Dock + if atom.config.get 'Zen.bottomPanel' + if panelBottom.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-bottom-dock' + ) + @restoreBottomDock = true + + # Enter fullscreen atom.setFullScreen true if fullscreen @@ -212,6 +243,23 @@ module.exports = ) @restoreMinimap = false + # Restore Right Dock + if @restoreRightDock + unless panelRight.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-right-dock' + ) + @restoreRightDock = false + + # Restore Bottom Dock + if @restoreBottomDock + unless panelRight.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-bottom-dock' + ) + @restoreBottomDock = false # Stop listening for pane or font change @fontChanged?.dispose() From 3533a27ddf8412573b0f53c400e31234c6e6d9c2 Mon Sep 17 00:00:00 2001 From: Matthew Slight Date: Sat, 13 Jan 2018 13:09:57 +0400 Subject: [PATCH 2/3] adds ability to have Zen hide the right and bottom panels, and provides toggle options in Zen config for users --- lib/zen.coffee | 66 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/lib/zen.coffee b/lib/zen.coffee index ae2c42c..13abb2e 100644 --- a/lib/zen.coffee +++ b/lib/zen.coffee @@ -28,16 +28,26 @@ module.exports = type: 'boolean' default: false order: 5 + bottomPanel: + description: 'Enables / Disables the bottom pane when Zen is active.' + type: 'boolean' + default: true + order: 7 + rightPanel: + description: 'Enables / Disables the right pane when Zen is active.' + type: 'boolean' + default: true + order: 7 width: type: 'integer' default: atom.config.get 'editor.preferredLineLength' - order: 6 + order: 8 tabs: description: 'Determines the tab style used while Zen is active.' type: 'string' default: 'hidden' enum: ['hidden', 'single', 'multiple'] - order: 7 + order: 9 showWordCount: description: 'Show the word-count if you have the package installed.' type: 'string' @@ -47,7 +57,7 @@ module.exports = 'Left', 'Right' ] - order: 8 + order: 10 activate: (state) -> atom.commands.add 'atom-workspace', 'zen:toggle', => @toggle() @@ -60,8 +70,8 @@ module.exports = return body = document.querySelector('body') - editor = atom.workspace.getActiveTextEditor() - editorElm = atom.workspace.getActiveTextEditor().element + editor = atom.workspace.getActiveTextEditor() + editorElm = atom.workspace.getActiveTextEditor().element # should really check current fullsceen state fullscreen = atom.config.get 'Zen.fullscreen' @@ -69,8 +79,10 @@ module.exports = softWrap = atom.config.get 'Zen.softWrap' minimap = atom.config.get 'Zen.minimap' - # Left panel needed for hide/restore - panel = atom.workspace.getLeftDock() + # Panels needed for hide/restore + panelLeft = atom.workspace.getLeftDock() + panelRight = atom.workspace.getRightDock() + panelBottom = atom.workspace.getBottomDock() if body.getAttribute('data-zen') isnt 'true' @@ -145,7 +157,7 @@ module.exports = # Hide TreeView if $('.nuclide-file-tree').length - if panel.isVisible() + if panelLeft.isVisible() atom.commands.dispatch( atom.views.getView(atom.workspace), 'nuclide-file-tree:toggle' @@ -166,6 +178,25 @@ module.exports = ) @restoreMinimap = true + # Hide Right Dock + if atom.config.get 'Zen.rightPanel' + if panelRight.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-right-dock' + ) + @restoreRightDock = true + + # Hide Bottom Dock + if atom.config.get 'Zen.bottomPanel' + if panelBottom.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-bottom-dock' + ) + @restoreBottomDock = true + + # Enter fullscreen atom.setFullScreen true if fullscreen @@ -192,7 +223,7 @@ module.exports = # Restore TreeView if @restoreTree if $('.nuclide-file-tree').length - unless panel.isVisible() + unless panelLeft.isVisible() atom.commands.dispatch( atom.views.getView(atom.workspace), 'nuclide-file-tree:toggle' @@ -212,6 +243,23 @@ module.exports = ) @restoreMinimap = false + # Restore Right Dock + if @restoreRightDock + unless panelRight.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-right-dock' + ) + @restoreRightDock = false + + # Restore Bottom Dock + if @restoreBottomDock + unless panelBottom.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'window:toggle-bottom-dock' + ) + @restoreBottomDock = false # Stop listening for pane or font change @fontChanged?.dispose() From 5eeb9e70a203a2492422fe1c39d09d6cb2e859b9 Mon Sep 17 00:00:00 2001 From: Matthew Slight Date: Sat, 13 Jan 2018 23:33:31 +0400 Subject: [PATCH 3/3] fix hide tree-view if not visible --- lib/zen.coffee | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/zen.coffee b/lib/zen.coffee index 07f530f..5265f9c 100644 --- a/lib/zen.coffee +++ b/lib/zen.coffee @@ -164,11 +164,12 @@ module.exports = ) @restoreTree = true else if $('.tree-view').length - atom.commands.dispatch( - atom.views.getView(atom.workspace), - 'tree-view:toggle' - ) - @restoreTree = true + if panelLeft.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'tree-view:toggle' + ) + @restoreTree = true # Hide Minimap if $('atom-text-editor /deep/ atom-text-editor-minimap').length and not minimap @@ -229,10 +230,11 @@ module.exports = 'nuclide-file-tree:toggle' ) else - atom.commands.dispatch( - atom.views.getView(atom.workspace), - 'tree-view:show' - ) + unless panelLeft.isVisible() + atom.commands.dispatch( + atom.views.getView(atom.workspace), + 'tree-view:show' + ) @restoreTree = false # Restore Minimap