Make meta-# bindings work with new panes

This commit is contained in:
Nathan Sobo
2013-03-01 17:36:16 -07:00
committed by probablycorey
parent f23d9091f2
commit d97e91bdcb
4 changed files with 34 additions and 12 deletions

View File

@@ -354,6 +354,15 @@ describe "Pane", ->
pane.trigger 'pane:show-next-item'
expect(pane.activeItem).toBe view1
describe "pane:show-item-N events", ->
it "shows the (n-1)th item if it exists", ->
pane.trigger 'pane:show-item-2'
expect(pane.activeItem).toBe pane.itemAtIndex(1)
pane.trigger 'pane:show-item-1'
expect(pane.activeItem).toBe pane.itemAtIndex(0)
pane.trigger 'pane:show-item-9' # don't fail on out-of-bounds indices
expect(pane.activeItem).toBe pane.itemAtIndex(0)
describe ".remove()", ->
it "destroys all the pane's items", ->
pane.remove()

View File

@@ -37,11 +37,19 @@
'ctrl--': 'pane:split-down'
'ctrl-w s': 'pane:split-down'
'.pane':
'meta-{': 'pane:show-previous-item'
'meta-}': 'pane:show-next-item'
'alt-meta-left': 'pane:show-previous-item'
'alt-meta-right': 'pane:show-next-item'
'meta-1': 'pane:show-item-1'
'meta-2': 'pane:show-item-2'
'meta-3': 'pane:show-item-3'
'meta-4': 'pane:show-item-4'
'meta-5': 'pane:show-item-5'
'meta-6': 'pane:show-item-6'
'meta-7': 'pane:show-item-7'
'meta-8': 'pane:show-item-8'
'meta-9': 'pane:show-item-9'
'.tool-panel':
'meta-escape': 'tool-panel:unfocus'

View File

@@ -16,15 +16,6 @@
'shift-tab': 'editor:outdent-selected-rows'
'meta-[': 'editor:outdent-selected-rows'
'meta-]': 'editor:indent-selected-rows'
'meta-1': 'editor:show-buffer-1'
'meta-2': 'editor:show-buffer-2'
'meta-3': 'editor:show-buffer-3'
'meta-4': 'editor:show-buffer-4'
'meta-5': 'editor:show-buffer-5'
'meta-6': 'editor:show-buffer-6'
'meta-7': 'editor:show-buffer-7'
'meta-8': 'editor:show-buffer-8'
'meta-9': 'editor:show-buffer-9'
'meta-/': 'editor:toggle-line-comments'
'ctrl-W': 'editor:select-word'
'meta-alt-p': 'editor:log-cursor-scope'

View File

@@ -26,6 +26,17 @@ class Pane extends View
@command 'pane:save-items', @saveItems
@command 'pane:show-next-item', @showNextItem
@command 'pane:show-previous-item', @showPreviousItem
@command 'pane:show-item-1', => @showItemAtIndex(0)
@command 'pane:show-item-2', => @showItemAtIndex(1)
@command 'pane:show-item-3', => @showItemAtIndex(2)
@command 'pane:show-item-4', => @showItemAtIndex(3)
@command 'pane:show-item-5', => @showItemAtIndex(4)
@command 'pane:show-item-6', => @showItemAtIndex(5)
@command 'pane:show-item-7', => @showItemAtIndex(6)
@command 'pane:show-item-8', => @showItemAtIndex(7)
@command 'pane:show-item-9', => @showItemAtIndex(8)
@command 'pane:split-left', => @splitLeft()
@command 'pane:split-right', => @splitRight()
@command 'pane:split-up', => @splitUp()
@@ -74,10 +85,13 @@ class Pane extends View
@items.indexOf(@activeItem)
showItemAtIndex: (index) ->
@showItem(@items[index])
@showItem(@itemAtIndex(index))
itemAtIndex: (index) ->
@items[index]
showItem: (item) ->
return if item is @activeItem
return if !item? or item is @activeItem
isFocused = @is(':has(:focus)')
@addItem(item)
view = @viewForItem(item)