aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/ex-mode/lib/ex-state.coffee
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/ex-mode/lib/ex-state.coffee
parent4efcafab7f0aa454f9ebe767133654bc9f44e12c (diff)
Remove Atom config
Diffstat (limited to 'atom/packages/ex-mode/lib/ex-state.coffee')
-rw-r--r--atom/packages/ex-mode/lib/ex-state.coffee63
1 files changed, 0 insertions, 63 deletions
diff --git a/atom/packages/ex-mode/lib/ex-state.coffee b/atom/packages/ex-mode/lib/ex-state.coffee
deleted file mode 100644
index 7c0f37c..0000000
--- a/atom/packages/ex-mode/lib/ex-state.coffee
+++ /dev/null
@@ -1,63 +0,0 @@
-{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
-
-Command = require './command'
-CommandError = require './command-error'
-
-class ExState
- constructor: (@editorElement, @globalExState) ->
- @emitter = new Emitter
- @subscriptions = new CompositeDisposable
- @editor = @editorElement.getModel()
- @opStack = []
- @history = []
-
- @registerOperationCommands
- open: (e) => new Command(@editor, @)
-
- destroy: ->
- @subscriptions.dispose()
-
- getExHistoryItem: (index) ->
- @globalExState.commandHistory[index]
-
- pushExHistory: (command) ->
- @globalExState.commandHistory.unshift command
-
- registerOperationCommands: (commands) ->
- for commandName, fn of commands
- do (fn) =>
- pushFn = (e) => @pushOperations(fn(e))
- @subscriptions.add(
- atom.commands.add(@editorElement, "ex-mode:#{commandName}", pushFn)
- )
-
- onDidFailToExecute: (fn) ->
- @emitter.on('failed-to-execute', fn)
-
- onDidProcessOpStack: (fn) ->
- @emitter.on('processed-op-stack', fn)
-
- pushOperations: (operations) ->
- @opStack.push operations
-
- @processOpStack() if @opStack.length == 2
-
- clearOpStack: ->
- @opStack = []
-
- processOpStack: ->
- [command, input] = @opStack
- if input.characters.length > 0
- @history.unshift command
- try
- command.execute(input)
- catch e
- if (e instanceof CommandError)
- atom.notifications.addError("Command error: #{e.message}")
- @emitter.emit('failed-to-execute')
- else
- throw e
- @clearOpStack()
- @emitter.emit('processed-op-stack')
-
-module.exports = ExState