       @busses[uri] = bus
     bus
 
+  startSCLang: (uri) ->
+    opts = @getPreferences()
+    opts.stdin = false
+    opts.echo = false
+    sclang = new SuperColliderJS.sclang(opts)
+    sclang.boot()
+
+    bus = @busForURI(uri)
+    sclang.on 'stdout', (d)->
+      bus.push("<pre>#{d}</pre>")
+    sclang.on 'stderr', (d)->
+      bus.push("<pre class='error'>#{d}</pre>")
+
+    @sclangs[uri] = sclang
+
   currentExpression: ->
     editor = atom.workspace.getActiveEditor()
     return unless editor?

PostWindow = require './post-window'
Bacon = require('baconjs')
url = require('url')
# SuperColliderJS = require 'supercolliderjs'
# Session = require './session'


module.exports =
class Controller

  constructor: (@workspaceView, directory) ->
    @postWindows = {}
    @busses = {}
    @activeURI = null
    @defaultURI = "sclang://localhost:57120"


      catch error
        return
      return unless protocol is 'sclang:'

      @startSCLang(uriToOpen)

      # returns it
      @createPostWindow(uriToOpen)
