1 class VimNormalModeInputElement extends HTMLDivElement
3 @className = "normal-mode-input"
5 initialize: (@viewModel, @mainEditorElement, opts = {}) ->
7 @classList.add(opts.class)
9 @editorElement = document.createElement "atom-text-editor"
10 @editorElement.classList.add('editor')
11 @editorElement.getModel().setMini(true)
12 @editorElement.setAttribute('mini', '')
13 @appendChild(@editorElement)
15 @singleChar = opts.singleChar
16 @defaultText = opts.defaultText ? ''
19 @classList.add('vim-hidden-normal-mode-input')
20 @mainEditorElement.parentNode.appendChild(this)
22 @panel = atom.workspace.addBottomPanel(item: this, priority: 100)
32 @editorElement.getModel().getBuffer().onDidChange (e) =>
33 @confirm() if e.newText and not compositing
34 @editorElement.addEventListener 'compositionstart', -> compositing = true
35 @editorElement.addEventListener 'compositionend', -> compositing = false
37 atom.commands.add(@editorElement, 'editor:newline', @confirm.bind(this))
39 atom.commands.add(@editorElement, 'core:confirm', @confirm.bind(this))
40 atom.commands.add(@editorElement, 'core:cancel', @cancel.bind(this))
41 atom.commands.add(@editorElement, 'blur', @cancel.bind(this))
44 @value = @editorElement.getModel().getText() or @defaultText
45 @viewModel.confirm(this)
49 @editorElement.focus()
52 @viewModel.cancel(this)
56 atom.workspace.getActivePane().activate()
63 document.registerElement("vim-normal-mode-input"
65 prototype: VimNormalModeInputElement.prototype