Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions lib/idris-controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ editorHelper = require './utils/editor'

class IdrisController

getCommands: ->
'language-idris:type-of': @runCommand @getTypeForWord
'language-idris:docs-for': @runCommand @getDocsForWord
'language-idris:case-split': @runCommand @doCaseSplit
'language-idris:add-clause': @runCommand @doAddClause
'language-idris:make-with': @runCommand @doMakeWith
'language-idris:make-lemma': @runCommand @doMakeLemma
'language-idris:make-case': @runCommand @doMakeCase
'language-idris:holes': @runCommand @showHoles
'language-idris:proof-search': @runCommand @doProofSearch
'language-idris:typecheck': @runCommand @typecheckFile
'language-idris:print-definition': @runCommand @printDefinition
'language-idris:stop-compiler': @stopCompiler
'language-idris:open-repl': @runCommand @openREPL
'language-idris:apropos': @runCommand @apropos

isIdrisFile: (uri) ->
uri?.match? /\.idr$/

Expand Down
44 changes: 39 additions & 5 deletions lib/language-idris.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
IdrisController = require './idris-controller'
{ CompositeDisposable } = require 'atom'
url = require 'url'
{ IdrisPanel } = require './views/panel-view'
IdrisPanel = undefined

module.exports =
config:
Expand All @@ -24,9 +23,7 @@ module.exports =
description: 'Enable ligatures in the various idris panels'

activate: ->
@controller = new IdrisController

subscription = atom.commands.add 'atom-text-editor[data-grammar~="idris"]', @controller.getCommands()
subscription = atom.commands.add 'atom-text-editor[data-grammar~="idris"]', @getCommands()
@subscriptions = new CompositeDisposable
@subscriptions.add subscription

Expand All @@ -38,8 +35,45 @@ module.exports =

return unless protocol is 'idris:'

if !IdrisPanel
{ IdrisPanel } = require './views/panel-view'

@loadController()
new IdrisPanel @controller, host

loadController: ->
if !@controller
IdrisController = require './idris-controller'
@controller = new IdrisController

runCommand: (command) ->
that = this

(args) ->
if !that.controller
that.loadController()

if command == 'stopCompiler'
that.controller.stopCompiler()
else
that.controller.runCommand(that.controller[command])(args)

getCommands: () ->
'language-idris:type-of': @runCommand 'getTypeForWord'
'language-idris:docs-for': @runCommand 'getDocsForWord'
'language-idris:case-split': @runCommand 'doCaseSplit'
'language-idris:add-clause': @runCommand 'doAddClause'
'language-idris:make-with': @runCommand 'doMakeWith'
'language-idris:make-lemma': @runCommand 'doMakeLemma'
'language-idris:make-case': @runCommand 'doMakeCase'
'language-idris:holes': @runCommand 'showHoles'
'language-idris:proof-search': @runCommand 'doProofSearch'
'language-idris:typecheck': @runCommand 'typecheckFile'
'language-idris:print-definition': @runCommand 'printDefinition'
'language-idris:stop-compiler': @runCommand 'stopCompiler'
'language-idris:open-repl': @runCommand 'openREPL'
'language-idris:apropos': @runCommand 'apropos'

deactivate: ->
@subscriptions.dispose()
this.controller.destroy()