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

Commit

Permalink
upgrade to API 1.0
Browse files Browse the repository at this point in the history
- use recommended selectors for keymaps
- use atom.commands to dispatch commands
- use compositedisposable and atom.commands to add and remove workspace commands
- use addBottomPanel to add the output-view
- use getActiveTextEditor instead of workspaceView.getActiveView()?.getEditor()
  • Loading branch information
jmquigs committed Jan 24, 2015
1 parent 5f23c75 commit a784d36
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions keymaps/ide-haskell.cson
Expand Up @@ -7,8 +7,8 @@

# For more detailed documentation see
# https://atom.io/docs/latest/advanced/keymaps
'.workspace':
'atom-workspace':
'ctrl-cmd-o': 'ide-haskell:toggle-output'

'.editor':
'atom-text-editor':
'ctrl-cmd-s': 'ide-haskell:prettify-file'
6 changes: 3 additions & 3 deletions lib/editor-control.coffee
Expand Up @@ -28,11 +28,11 @@ class EditorControl
return unless isHaskellSource buffer.getUri()

# TODO if uri was changed, then we have to remove all current markers

workspaceElement = atom.views.getView(atom.workspace)
if atom.config.get('ide-haskell.checkOnFileSave')
atom.workspaceView.trigger 'ide-haskell:check-file'
atom.commands.dispatch workspaceElement, 'ide-haskell:check-file'
if atom.config.get('ide-haskell.lintOnFileSave')
atom.workspaceView.trigger 'ide-haskell:lint-file'
atom.commands.dispatch workspaceElement, 'ide-haskell:lint-file'

# show expression type if mouse stopped somewhere
@subscriber.subscribe @scroll, 'mousemove', (e) =>
Expand Down
26 changes: 13 additions & 13 deletions lib/ide-haskell.coffee
Expand Up @@ -2,7 +2,7 @@

{PluginManager} = require './plugin-manager'
{isCabalProject} = require './utils'

{CompositeDisposable} = require 'atom'

configDefaults =
checkOnFileSave: true,
Expand All @@ -14,6 +14,7 @@ configDefaults =

_isCabalProject = false # true if cabal project
_pluginManager = null # plugin manager
_disposables = new CompositeDisposable

activate = (state) ->
_isCabalProject = isCabalProject()
Expand All @@ -23,14 +24,15 @@ activate = (state) ->
_pluginManager = new PluginManager(state)

# global commands
atom.workspaceView.command 'ide-haskell:toggle-output', ->
_pluginManager.togglePanel()
atom.workspaceView.command 'ide-haskell:check-file', ->
_pluginManager.checkFile()
atom.workspaceView.command 'ide-haskell:lint-file', ->
_pluginManager.lintFile()
atom.workspaceView.command 'ide-haskell:prettify-file', ->
_pluginManager.prettifyFile(true)
_disposables.add atom.commands.add 'atom-workspace',
'ide-haskell:toggle-output': ->
_pluginManager.togglePanel()
'ide-haskell:check-file': ->
_pluginManager.checkFile()
'ide-haskell:lint-file': ->
_pluginManager.lintFile()
'ide-haskell:prettify-file': ->
_pluginManager.prettifyFile(true)

updateMenu()

Expand All @@ -43,10 +45,8 @@ deactivate = ->
_pluginManager = null

# clear commands
atom.workspaceView.off 'ide-haskell:toggle-output'
atom.workspaceView.off 'ide-haskell:check-file'
atom.workspaceView.off 'ide-haskell:lint-file'
atom.workspaceView.off 'ide-haskell:prettify-output'
_disposables.dispose();
_disposables = new CompositeDisposable

clearMenu()

Expand Down
3 changes: 2 additions & 1 deletion lib/output-view.coffee
Expand Up @@ -59,7 +59,8 @@ class OutputView extends View
if @isShow then @attach() else @detach()

attach: ->
atom.workspaceView.prependToBottom(this)
atom.workspace.addBottomPanel
item: this

resizeStarted: ({pageY}) =>
@resizeData =
Expand Down
5 changes: 3 additions & 2 deletions lib/plugin-manager.coffee
Expand Up @@ -42,7 +42,7 @@ class PluginManager

# File prettify
prettifyFile: ->
editor = atom.workspaceView.getActiveView()?.getEditor()
editor = atom.workspace.getActiveTextEditor()
fileName = editor?.getPath()
return unless fileName?

Expand All @@ -61,7 +61,8 @@ class PluginManager
# File check or lint.
checkOrLintFile: (func) ->
return if @checkTurnedOff? and @checkTurnedOff
fileName = atom.workspaceView.getActiveView()?.getEditor().getPath()
editor = atom.workspace.getActiveTextEditor()
fileName = editor?.getPath()
return unless fileName?

@outputView?.pendingCheck()
Expand Down

0 comments on commit a784d36

Please sign in to comment.