aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/vim-mode/lib/view-models
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2019-03-14 23:19:58 +0100
committerBen Beltran <ben@nsovocal.com>2019-03-14 23:19:58 +0100
commitb009b50e81b6c1d0d691505b5f5c0418f559bfc0 (patch)
tree5fae800e76219eba28634cb236565f9b4bb7a2f7 /atom/packages/vim-mode/lib/view-models
parent4efcafab7f0aa454f9ebe767133654bc9f44e12c (diff)
Remove Atom config
Diffstat (limited to 'atom/packages/vim-mode/lib/view-models')
-rw-r--r--atom/packages/vim-mode/lib/view-models/search-view-model.coffee50
-rw-r--r--atom/packages/vim-mode/lib/view-models/view-model.coffee25
-rw-r--r--atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee66
3 files changed, 0 insertions, 141 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
deleted file mode 100644
index 8e63fd2..0000000
--- a/atom/packages/vim-mode/lib/view-models/search-view-model.coffee
+++ /dev/null
@@ -1,50 +0,0 @@
-{ViewModel} = require './view-model'
-
-module.exports =
-class SearchViewModel extends ViewModel
- constructor: (@searchMotion) ->
- super(@searchMotion, class: 'search')
- @historyIndex = -1
-
- atom.commands.add(@view.editorElement, 'core:move-up', @increaseHistorySearch)
- atom.commands.add(@view.editorElement, 'core:move-down', @decreaseHistorySearch)
-
- restoreHistory: (index) ->
- @view.editorElement.getModel().setText(@history(index))
-
- history: (index) ->
- @vimState.getSearchHistoryItem(index)
-
- increaseHistorySearch: =>
- if @history(@historyIndex + 1)?
- @historyIndex += 1
- @restoreHistory(@historyIndex)
-
- decreaseHistorySearch: =>
- if @historyIndex <= 0
- # get us back to a clean slate
- @historyIndex = -1
- @view.editorElement.getModel().setText('')
- else
- @historyIndex -= 1
- @restoreHistory(@historyIndex)
-
- confirm: (view) =>
- repeatChar = if @searchMotion.initiallyReversed then '?' else '/'
- if @view.value is '' or @view.value is repeatChar
- lastSearch = @history(0)
- if lastSearch?
- @view.value = lastSearch
- else
- @view.value = ''
- 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
deleted file mode 100644
index b9da169..0000000
--- a/atom/packages/vim-mode/lib/view-models/view-model.coffee
+++ /dev/null
@@ -1,25 +0,0 @@
-VimNormalModeInputElement = require './vim-normal-mode-input-element'
-
-class ViewModel
- constructor: (@operation, opts={}) ->
- {@editor, @vimState} = @operation
- @view = new VimNormalModeInputElement().initialize(this, atom.views.getView(@editor), opts)
- @editor.normalModeInputView = @view
- @vimState.onDidFailToCompose => @view.remove()
-
- confirm: (view) ->
- @vimState.pushOperations(new Input(@view.value))
-
- cancel: (view) ->
- if @vimState.isOperatorPending()
- @vimState.pushOperations(new Input(''))
- delete @editor.normalModeInputView
-
-class Input
- constructor: (@characters) ->
- isComplete: -> true
- isRecordable: -> true
-
-module.exports = {
- ViewModel, Input
-}
diff --git a/atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee b/atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee
deleted file mode 100644
index 2371753..0000000
--- a/atom/packages/vim-mode/lib/view-models/vim-normal-mode-input-element.coffee
+++ /dev/null
@@ -1,66 +0,0 @@
-class VimNormalModeInputElement extends HTMLDivElement
- createdCallback: ->
- @className = "normal-mode-input"
-
- initialize: (@viewModel, @mainEditorElement, opts = {}) ->
- if opts.class?
- @classList.add(opts.class)
-
- @editorElement = document.createElement "atom-text-editor"
- @editorElement.classList.add('editor')
- @editorElement.getModel().setMini(true)
- @editorElement.setAttribute('mini', '')
- @appendChild(@editorElement)
-
- @singleChar = opts.singleChar
- @defaultText = opts.defaultText ? ''
-
- 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()
-
- this
-
- handleEvents: ->
- if @singleChar?
- compositing = false
- @editorElement.getModel().getBuffer().onDidChange (e) =>
- @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))
-
- atom.commands.add(@editorElement, 'core:confirm', @confirm.bind(this))
- atom.commands.add(@editorElement, 'core:cancel', @cancel.bind(this))
- atom.commands.add(@editorElement, 'blur', @cancel.bind(this))
-
- confirm: ->
- @value = @editorElement.getModel().getText() or @defaultText
- @viewModel.confirm(this)
- @removePanel()
-
- focus: ->
- @editorElement.focus()
-
- cancel: (e) ->
- @viewModel.cancel(this)
- @removePanel()
-
- removePanel: ->
- atom.workspace.getActivePane().activate()
- if @panel?
- @panel.destroy()
- else
- this.remove()
-
-module.exports =
-document.registerElement("vim-normal-mode-input"
- extends: "div",
- prototype: VimNormalModeInputElement.prototype
-)