Add MoveUp command to VimMode

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-13 10:57:08 -08:00
parent 257ae7f67d
commit ca2b7c9fd1
4 changed files with 34 additions and 15 deletions

View File

@@ -66,3 +66,6 @@ class Editor extends Template
moveLeft: ->
@aceEditor.navigateLeft()
moveUp: ->
@aceEditor.navigateUp()

View File

@@ -29,3 +29,11 @@ module.exports =
editor.moveLeft() if column > 0
isComplete: -> true
MoveUp: class
execute: (editor) ->
{column, row} = editor.getCursor()
editor.moveUp() if row > 0
isComplete: -> true

View File

@@ -1,6 +1,6 @@
_ = require 'underscore'
$ = require 'jquery'
{ NumericPrefix, DeleteChar, MoveLeft } = require 'vim-mode-operators'
{ NumericPrefix, DeleteChar, MoveLeft, MoveUp} = require 'vim-mode-operators'
module.exports =
class VimMode
@@ -17,9 +17,13 @@ class VimMode
@editor.on 'insert-mode:activate', => @activateInsertMode()
@editor.on 'command-mode:activate', => @activateCommandMode()
@editor.on 'command-mode:delete-char', => @deleteChar()
@editor.on 'command-mode:numeric-prefix', (e) => @numericPrefix(e)
@editor.on 'command-mode:delete-char', => @pushOperator(new DeleteChar)
@editor.on 'command-mode:numeric-prefix', (e) => @pushOperator(new NumericPrefix(e.keyEvent.char))
@editor.on 'command-mode:move-left', => @pushOperator(new MoveLeft)
@editor.on 'command-mode:move-up', => @pushOperator(new MoveUp)
registerCommand: (name, handler) ->
@editor.on "command-mode:#{name}", handler
activateInsertMode: ->
@editor.removeClass('command-mode')
@@ -29,17 +33,12 @@ class VimMode
@editor.removeClass('insert-mode')
@editor.addClass('command-mode')
deleteChar: ->
@pushOperator(new DeleteChar)
numericPrefix: (e) ->
@pushOperator(new NumericPrefix(e.keyEvent.char))
commandModeBindings: ->
bindings =
'i': 'insert-mode:activate'
'x': 'command-mode:delete-char'
'h': 'command-mode:move-left'
'j': 'command-mode:move-up'
for i in [0..9]
bindings[i] = 'command-mode:numeric-prefix'
bindings