Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
Auto hide option, settings order
Browse files Browse the repository at this point in the history
Closes #185
  • Loading branch information
lierdakil committed Jan 15, 2017
1 parent 6a9b115 commit 32906a5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 17 deletions.
18 changes: 17 additions & 1 deletion lib/ide-haskell.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ module.exports = IdeHaskell =
type: "boolean"
default: false
description: "Run file through stylish-haskell before save"

order: 20
switchTabOnCheck:
type: "boolean"
default: true
description: "Switch to error tab after file check finished"
order: 10
expressionTypeInterval:
type: "integer"
default: 300
description: "Type/Info tooltip show delay, in ms"
order: 30
onCursorMove:
type: 'string'
description: '''
Expand All @@ -26,38 +28,52 @@ module.exports = IdeHaskell =
'''
enum: ['Show Tooltip', 'Hide Tooltip', 'Nothing']
default: 'Nothing'
order: 40
stylishHaskellPath:
type: "string"
default: 'stylish-haskell'
description: "Path to `stylish-haskell` utility or other prettifier"
order: 60
stylishHaskellArguments:
type: 'array'
default: []
description: 'Additional arguments to pass to prettifier; comma-separated'
items:
type: 'string'
order: 70
cabalPath:
type: "string"
default: 'cabal'
description: "Path to `cabal` utility, for `cabal format`"
order: 50
startupMessageIdeBackend:
type: "boolean"
default: true
description: "Show info message about haskell-ide-backend service on
activation"
order: 80
panelPosition:
type: 'string'
default: 'bottom'
description: '''
Output panel position
'''
enum: ['bottom', 'left', 'top', 'right']
order: 41
hideParameterValues:
type: 'boolean'
default: false
description: '''
Hide additional plugin parameter values until hovered
'''
order: 12
autoHideOutput:
type: 'boolean'
default: false
description: '''
Hide panel output when there are no new messages to show
'''
order: 11

cleanConfig: ->
[ 'onSaveCheck'
Expand Down
11 changes: 8 additions & 3 deletions lib/output-panel/views/output-panel-buttons.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ class OutputPanelButtons extends HTMLElement
buttonNames: ->
Object.keys @buttons

clickButton: (btn) ->
clickButton: (btn, force = false) ->
if @buttons[btn]?
isActive = @buttons[btn].element.classList.contains 'active'
for v in @getElementsByClassName 'active'
v.classList.remove 'active'
@buttons[btn].element.classList.add 'active'
@buttons[btn].element.classList.add 'active' if not isActive or force
@emitter.emit 'button-clicked', btn

disableAll: ->
for v in @getElementsByClassName 'active'
v.classList.remove 'active'

setCount: (btn, count) ->
if @buttons[btn]?
@buttons[btn].element.setAttribute 'data-count', count
Expand All @@ -55,7 +60,7 @@ class OutputPanelButtons extends HTMLElement
@disposables.dispose()

getActive: ->
@getElementsByClassName('active')[0]?.getAttribute?('data-caption')
@getElementsByClassName('active')[0]?.getAttribute?('data-caption') ? null

OutputPanelButtonsElement =
document.registerElement 'ide-haskell-panel-buttons',
Expand Down
34 changes: 21 additions & 13 deletions lib/output-panel/views/output-panel.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ module.exports=
class OutputPanelView extends HTMLElement
setModel: (@model) ->
@disposables.add @model.results.onDidUpdate ({types}) =>
if atom.config.get('ide-haskell.switchTabOnCheck')
@activateFirstNonEmptyTab types
if atom.config.get('ide-haskell.autoHideOutput') and \
types.map((type) => @model.results.filter(severity: type).length).every((l) -> l is 0)
@buttons.disableAll()
else
if atom.config.get('ide-haskell.switchTabOnCheck')
@activateFirstNonEmptyTab types
@updateItems()
@items.setModel @model.results

@style.height = @model.state.height if @model.state?.height?
@style.width = @model.state.width if @model.state?.width?
@activateTab(@model.state.activeTab ? @buttons.buttonNames()[0])
@activateTab(@model.state.activeTab) if @model.state?.activeTab?
if @model.state?.activeTab is undefined
@activateTab(@buttons.buttonNames()[0])
@checkboxUriFilter.setFileFilter @model.state.fileFilter

@
Expand Down Expand Up @@ -131,21 +137,25 @@ class OutputPanelView extends HTMLElement
document.documentElement.addEventListener 'mouseup', stopDrag
updateItems: ->
activeTab = @getActiveTab()
filter = severity: activeTab
if @checkboxUriFilter.getFileFilter()
uri = atom.workspace.getActiveTextEditor()?.getPath?()
filter.uri = uri if uri? and @buttons.options(activeTab).uriFilter
scroll = @buttons.options(activeTab).autoScroll and @items.atEnd()
@items.filter filter
@items.scrollToEnd() if scroll
if activeTab?
@classList.remove 'hidden-output'
filter = severity: activeTab
if @checkboxUriFilter.getFileFilter()
uri = atom.workspace.getActiveTextEditor()?.getPath?()
filter.uri = uri if uri? and @buttons.options(activeTab).uriFilter
scroll = @buttons.options(activeTab).autoScroll and @items.atEnd()
@items.filter filter
@items.scrollToEnd() if scroll
else
@classList.add 'hidden-output'

for btn in @buttons.buttonNames()
f = severity: btn
f.uri = uri if uri? and @buttons.options(btn).uriFilter
@buttons.setCount btn, @model.results.filter(f).length

activateTab: (tab) ->
@buttons.clickButton tab
@buttons.clickButton tab, true

activateFirstNonEmptyTab: (types) ->
for name in @buttons.buttonNames() when (if types? then name in types else true)
Expand All @@ -172,8 +182,6 @@ class OutputPanelView extends HTMLElement
createTab: (name, opts) ->
unless name in @buttons.buttonNames()
@buttons.createButton name, opts
unless @getActiveTab()?
@activateTab @buttons.buttonNames()[0]

setProgress: (progress) ->
switch atom.config.get('ide-haskell.panelPosition')
Expand Down
3 changes: 3 additions & 0 deletions lib/results-db.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ class ResultsDB
@results.filter (item) ->
b = (item[k] is v for k, v of template)
b.every (v) -> v

isEmpty: ->
@results.length is 0
10 changes: 10 additions & 0 deletions styles/ide-haskell.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ ide-haskell-panel {
position: absolute;
}

&.hidden-output {
height: auto !important;
width: auto !important;
min-height: inherit !important;
min-width: inherit !important;
ide-haskell-panel-items {
display: none;
}
}

&[data-pos=top], &[data-pos=bottom] {
min-height: 120px;
max-height: 50vh;
Expand Down

0 comments on commit 32906a5

Please sign in to comment.