         return @
 
     output: ->
-        if @mode isnt OUTPUT
-            @mode = OUTPUT
-            log 'Panel', "output mode"
-            @show()
-            @content.show()
-            @inputBox.hide()
+        @switchMode OUTPUT
         return @
 
     activateIM: ->
-        if @mode isnt IM
-            @mode = IM
-            log 'Panel', "IM mode on"
-            @show()
+        if not @IM
+            @IM = true
+            log 'Panel', "IM on"
             @title.hide()
             @inputMethod.show()
         return @
 
     deactivateIM: ->
-        if @mode is IM
-            @mode = OUTPUT
-            log 'Panel', "IM mode off"
-            @show()
+        if @IM
+            @IM = false
+            log 'Panel', "IM off"
             @title.show()
             @inputMethod.hide()
         return @

    #   Modes
    #

    query: ->
        if @mode isnt QUERY
            @mode = QUERY

            log 'Panel', "query mode"
            @show()
            @content.hide()
            @inputBox.show()

            @inputBox.focus()
            @promise = Q.Promise (resolve, reject, notify) =>
                # confirm

HIDE = 0
OUTPUT = 1
QUERY = 2

class PanelView extends View

    mode: HIDE
    IM: false

    @content: ->
        @div outlet: 'agdaPanel', class: 'agda-panel tool-panel panel-bottom', =>
