1 class ExCommandModeInputElement extends HTMLDivElement
3 @className = "command-mode-input"
5 @editorContainer = document.createElement("div")
6 @editorContainer.className = "editor-container"
8 @appendChild(@editorContainer)
10 initialize: (@viewModel, opts = {}) ->
12 @editorContainer.classList.add(opts.class)
15 @editorContainer.style.height = "0px"
17 @editorElement = document.createElement "atom-text-editor"
18 @editorElement.classList.add('editor')
19 @editorElement.getModel().setMini(true)
20 @editorElement.setAttribute('mini', '')
21 @editorContainer.appendChild(@editorElement)
23 @singleChar = opts.singleChar
24 @defaultText = opts.defaultText ? ''
26 @panel = atom.workspace.addBottomPanel(item: this, priority: 100)
35 @editorElement.getModel().getBuffer().onDidChange (e) =>
36 @confirm() if e.newText
38 atom.commands.add(@editorElement, 'editor:newline', @confirm.bind(this))
40 atom.commands.add(@editorElement, 'core:confirm', @confirm.bind(this))
41 atom.commands.add(@editorElement, 'core:cancel', @cancel.bind(this))
42 atom.commands.add(@editorElement, 'blur', @cancel.bind(this))
45 @value = @editorElement.getModel().getText() or @defaultText
46 @viewModel.confirm(this)
50 @editorElement.focus()
53 @viewModel.cancel(this)
57 atom.workspace.getActivePane().activate()
61 document.registerElement("ex-command-mode-input"
63 prototype: ExCommandModeInputElement.prototype