 {Emitter} = require 'atom'
 {CompositeDisposable} = require 'atom'
+_ = require 'underscore-plus'
 
 class Input
   subscriptions: null
+
   constructor: (@vimState) ->
     @emitter = new Emitter
     @view = atom.views.getView(this)
     @vimState.onDidFailToCompose =>
       @view.cancel()
 
-  onDidGet: ({charsMax, defaultInput}={}, callback) ->
+  onDidGet: (spec={}, callback) ->
     @subscriptions ?= new CompositeDisposable
-    @view.charsMax = charsMax ? 1
-    @view.defaultInput = defaultInput ? ''
+    @view.setSpec(spec)
     @subscriptions.add @emitter.on 'did-get', callback
 
   onDidChange: (callback) ->

      return if @finishing
      text = @editor.getText()
      @model.emitter.emit 'did-change', text
      if text.length >= @charsMax
        @confirm()

  confirm: ->
    if input = (@editor.getText() or @defaultInput)
      # console.log "called confirm with '#{input}'"
      @model.emitter.emit 'did-get', input
      @unfocus()


class InputElement extends HTMLElement
  finishing: false
  spec: null

  createdCallback: ->
    @className = 'vim-mode-input'
