meta-{ goes to previous buffer

This commit is contained in:
Corey Johnson
2012-04-11 13:41:54 -07:00
parent bf367863ba
commit 5097218aa2
3 changed files with 26 additions and 2 deletions

View File

@@ -85,6 +85,7 @@ class Editor extends View
@on 'split-down', => @splitDown()
@on 'close', => @remove(); false
@on 'show-next-buffer', => @loadNextEditorState()
@on 'show-previous-buffer', => @loadPreviousEditorState()
@on 'move-to-top', => @moveCursorToTop()
@on 'move-to-bottom', => @moveCursorToBottom()
@@ -251,6 +252,12 @@ class Editor extends View
nextIndex = (index + 1) % @editorStates.length
@setEditorState(@editorStates[nextIndex])
loadPreviousEditorState: ->
index = @indexOfEditorState(@getEditorState())
if index?
previousIndex = if --index >= 0 then index else @editorStates.length - 1
@setEditorState(@editorStates[previousIndex])
setEditorState: (editorState={}) ->
buffer = editorState.buffer ?= new Buffer
@setEditorStateForBuffer(buffer, editorState)

View File

@@ -31,4 +31,5 @@ window.keymap.bindKeys '.editor',
'alt-meta-down': 'split-down'
'meta-[': 'outdent-selected-rows'
'meta-]': 'indent-selected-rows'
'meta-{': 'show-previous-buffer'
'meta-}': 'show-next-buffer'