aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/vim-mode/lib/view-models
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2015-09-28 12:39:59 -0500
committerBen Beltran <ben@nsovocal.com>2015-09-28 12:39:59 -0500
commit455f099b504ec07dd492ab31987ae05a6f6774c7 (patch)
tree22b0c7fd8e492733b97e661750a2d79c46da451d /atom/packages/vim-mode/lib/view-models
parent24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a (diff)
Adds atom packages
Diffstat (limited to 'atom/packages/vim-mode/lib/view-models')
-rw-r--r--atom/packages/vim-mode/lib/view-models/search-view-model.coffee8
-rw-r--r--atom/packages/vim-mode/lib/view-models/view-model.coffee7
-rw-r--r--atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee (renamed from atom/packages/vim-mode/lib/view-models/vim-command-mode-input-element.coffee)38
3 files changed, 32 insertions, 21 deletions
diff --git a/atom/packages/vim-mode/lib/view-models/search-view-model.coffee b/atom/packages/vim-mode/lib/view-models/search-view-model.coffee
index 8787210..8e63fd2 100644
--- a/atom/packages/vim-mode/lib/view-models/search-view-model.coffee
+++ b/atom/packages/vim-mode/lib/view-models/search-view-model.coffee
@@ -40,3 +40,11 @@ class SearchViewModel extends ViewModel
atom.beep()
super(view)
@vimState.pushSearchHistory(@view.value)
+
+ update: (reverse) ->
+ if reverse
+ @view.classList.add('reverse-search-input')
+ @view.classList.remove('search-input')
+ else
+ @view.classList.add('search-input')
+ @view.classList.remove('reverse-search-input')
diff --git a/atom/packages/vim-mode/lib/view-models/view-model.coffee b/atom/packages/vim-mode/lib/view-models/view-model.coffee
index 9cc63e1..b9da169 100644
--- a/atom/packages/vim-mode/lib/view-models/view-model.coffee
+++ b/atom/packages/vim-mode/lib/view-models/view-model.coffee
@@ -1,10 +1,10 @@
-VimCommandModeInputElement = require './vim-command-mode-input-element'
+VimNormalModeInputElement = require './vim-normal-mode-input-element'
class ViewModel
constructor: (@operation, opts={}) ->
{@editor, @vimState} = @operation
- @view = new VimCommandModeInputElement().initialize(this, opts)
- @editor.commandModeInputView = @view
+ @view = new VimNormalModeInputElement().initialize(this, atom.views.getView(@editor), opts)
+ @editor.normalModeInputView = @view
@vimState.onDidFailToCompose => @view.remove()
confirm: (view) ->
@@ -13,6 +13,7 @@ class ViewModel
cancel: (view) ->
if @vimState.isOperatorPending()
@vimState.pushOperations(new Input(''))
+ delete @editor.normalModeInputView
class Input
constructor: (@characters) ->
diff --git a/atom/packages/vim-mode/lib/view-models/vim-command-mode-input-element.coffee b/atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee
index 4fd0c52..2371753 100644
--- a/atom/packages/vim-mode/lib/view-models/vim-command-mode-input-element.coffee
+++ b/atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee
@@ -1,29 +1,25 @@
-class VimCommandModeInputElement extends HTMLDivElement
+class VimNormalModeInputElement extends HTMLDivElement
createdCallback: ->
- @className = "command-mode-input"
+ @className = "normal-mode-input"
- @editorContainer = document.createElement("div")
- @editorContainer.className = "editor-container"
-
- @appendChild(@editorContainer)
-
- initialize: (@viewModel, opts = {}) ->
+ initialize: (@viewModel, @mainEditorElement, opts = {}) ->
if opts.class?
- @editorContainer.classList.add(opts.class)
-
- if opts.hidden
- @editorContainer.style.height = "0px"
+ @classList.add(opts.class)
@editorElement = document.createElement "atom-text-editor"
@editorElement.classList.add('editor')
@editorElement.getModel().setMini(true)
@editorElement.setAttribute('mini', '')
- @editorContainer.appendChild(@editorElement)
+ @appendChild(@editorElement)
@singleChar = opts.singleChar
@defaultText = opts.defaultText ? ''
- @panel = atom.workspace.addBottomPanel(item: this, priority: 100)
+ if opts.hidden
+ @classList.add('vim-hidden-normal-mode-input')
+ @mainEditorElement.parentNode.appendChild(this)
+ else
+ @panel = atom.workspace.addBottomPanel(item: this, priority: 100)
@focus()
@handleEvents()
@@ -32,8 +28,11 @@ class VimCommandModeInputElement extends HTMLDivElement
handleEvents: ->
if @singleChar?
+ compositing = false
@editorElement.getModel().getBuffer().onDidChange (e) =>
- @confirm() if e.newText
+ @confirm() if e.newText and not compositing
+ @editorElement.addEventListener 'compositionstart', -> compositing = true
+ @editorElement.addEventListener 'compositionend', -> compositing = false
else
atom.commands.add(@editorElement, 'editor:newline', @confirm.bind(this))
@@ -55,10 +54,13 @@ class VimCommandModeInputElement extends HTMLDivElement
removePanel: ->
atom.workspace.getActivePane().activate()
- @panel.destroy()
+ if @panel?
+ @panel.destroy()
+ else
+ this.remove()
module.exports =
-document.registerElement("vim-command-mode-input"
+document.registerElement("vim-normal-mode-input"
extends: "div",
- prototype: VimCommandModeInputElement.prototype
+ prototype: VimNormalModeInputElement.prototype
)