Skip to content

New feature to hide the right and bottom panels #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
92 changes: 71 additions & 21 deletions lib/zen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,26 @@ module.exports =
type: 'boolean'
default: false
order: 5
rightPanel:
description: 'Enables / Disables the right pane when Zen is active.'
type: 'boolean'
default: true
order: 6
bottomPanel:
description: 'Enables / Disables the bottom 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'
Expand All @@ -47,7 +57,7 @@ module.exports =
'Left',
'Right'
]
order: 8
order: 10

activate: (state) ->
atom.commands.add 'atom-workspace', 'zen:toggle', => @toggle()
Expand All @@ -60,17 +70,19 @@ 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'
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'

Expand Down Expand Up @@ -145,18 +157,19 @@ 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'
)
@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
Expand All @@ -166,6 +179,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

Expand All @@ -192,16 +224,17 @@ 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'
)
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
Expand All @@ -212,6 +245,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()
Expand Down