             if secondPart.length == 1
               buffer.addStringToInput secondPart
 
-    return+    return
+
+  off: ->
+    @resizeHandle.removeEventListener 'mousedown', @resizeStarted
+    @resizeHandle.removeEventListener 'dblclick', @resizeToMinSize
+    @element.removeEventListener 'keydown', @dispatchKeyEvent
+    @element.removeEventListener 'focusin', @focusTerminal
+    @element.removeEventListener 'focusout', @blurTerminal
    sizeDiff = (heightDiff - (heightDiff % lineHeight)) / lineHeight
    if sizeDiff isnt 0
      size = @activeTerminal.getSize()
      @activeTerminal.setSize(size+sizeDiff)

  resizeToMinSize: =>
    @activeTerminal.setSize(terminalUtils.MIN_SIZE)

  doShowTerminal: ->
    workspaceView = atom.views.getView(atom.workspace)
    atom.commands.dispatch(workspaceView,'levels:toggle-terminal')

  doHideTerminal: ->
    workspaceView = atom.views.getView(atom.workspace)
    atom.commands.dispatch(workspaceView,'levels:toggle-terminal')

  doClearTerminal: ->
    workspaceView = atom.views.getView(atom.workspace)
    atom.commands.dispatch(workspaceView,'levels:clear-terminal')

  doScrollTerminalToTop: ->
    @activeTerminal.scrollToTop()


  updateOnDidExitWorkspace: ->
    @hide()
    @activeTerminalSubscriptions?.dispose()
    @activeLanguageSubscription?.dispose()
    @activeTerminal = null
    @activeLanguage = null
    @fontSizeSelect.removeEventListener 'change', @onDidChangeFontSize
    @off()

  updateOnDidChangeActiveLanguageOfWorkspace: (@activeLanguage) ->
    @activeLanguageSubscription?.dispose()
    @activeLanguageSubscription = @activeLanguage.observe => @updateOnDidChangeActiveLanguage()

  updateOnDidChangeActiveTerminalOfWorkspace: (@activeTerminal) ->
    @activeTerminalSubscriptions?.dispose()
    @activeTerminalSubscriptions = new CompositeDisposable()
    @activeTerminalSubscriptions.add @activeTerminal.observeIsVisible (isVisible) => @updateOnDidChangeIsVisibleOfActiveTerminal(isVisible)
    @activeTerminalSubscriptions.add @activeTerminal.onDidChangeSize (size) => @updateOnDidChangeTerminalSize(size)
    @activeTerminalSubscriptions.add @activeTerminal.observeFontSize (fontSize) => @updateOnDidChangeTerminalFontSize(fontSize)
    @activeTerminalSubscriptions.add @activeTerminal.observeIsExecuting (isExecuting) => @updateOnDidChangeIsExecutingOfActiveTerminal(isExecuting)

    @terminalContainer.innerHTML = ''
    @terminalContainer.appendChild(atom.views.getView(@activeTerminal))

  updateOnDidChangeActiveLanguage: ->
    unless @activeTerminal.isExecuting()
      if @activeLanguage.isExecutable()
        @startExecutionLink.style.display = ''
