     activated: false
     mute: false
 
+    subscriptions: null
     # raw characters
     rawInput: ''
     # visual marker
     textBufferMarker: null
 
     constructor: (@core) ->
+
+        # intercept newline `\n` as confirm
+        commands =
+            'editor:newline': (ev) =>
+                if @activated
+                    @deactivate()
+                    ev.stopImmediatePropagation()
+
+        @subscriptions = new CompositeDisposable
+        @subscriptions.add atom.commands.add 'atom-text-editor.agda-mode-input-method-activated', commands
+
+    destroy: ->
+        @subscriptions.destroy()
+
     activate: ->
         if not @activated
 

            log 'IM', 'activated'
            @rawInput = ''
            @activated = true

            # add class 'agda-mode-input-method-activated'
            editorElement = atom.views.getView(atom.workspace.getActiveTextEditor())

{CompositeDisposable, Range} = require 'atom'
{log} = require './logger'
Keymap = require './input-method/keymap'

