aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/ex-mode/lib/view-model.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'atom/packages/ex-mode/lib/view-model.coffee')
-rw-r--r--atom/packages/ex-mode/lib/view-model.coffee26
1 files changed, 26 insertions, 0 deletions
diff --git a/atom/packages/ex-mode/lib/view-model.coffee b/atom/packages/ex-mode/lib/view-model.coffee
new file mode 100644
index 0000000..af96e77
--- /dev/null
+++ b/atom/packages/ex-mode/lib/view-model.coffee
@@ -0,0 +1,26 @@
+ExCommandModeInputElement = require './ex-command-mode-input-element'
+
+class ViewModel
+ constructor: (@command, opts={}) ->
+ {@editor, @exState} = @command
+
+ @view = new ExCommandModeInputElement().initialize(@, opts)
+ @editor.commandModeInputView = @view
+ @exState.onDidFailToExecute => @view.remove()
+ @done = false
+
+ confirm: (view) ->
+ @exState.pushOperations(new Input(@view.value))
+ @done = true
+
+ cancel: (view) ->
+ unless @done
+ @exState.pushOperations(new Input(''))
+ @done = true
+
+class Input
+ constructor: (@characters) ->
+
+module.exports = {
+ ViewModel, Input
+}