From d97e91bdcb5baabd88d77098f86aba97abffe2a7 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 1 Mar 2013 17:36:16 -0700 Subject: [PATCH] Make meta-# bindings work with new panes --- spec/app/pane-spec.coffee | 9 +++++++++ src/app/keymaps/atom.cson | 10 +++++++++- src/app/keymaps/editor.cson | 9 --------- src/app/pane.coffee | 18 ++++++++++++++++-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index 103aa13ba..f1344ba31 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -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() diff --git a/src/app/keymaps/atom.cson b/src/app/keymaps/atom.cson index 29e83880a..c621867c3 100644 --- a/src/app/keymaps/atom.cson +++ b/src/app/keymaps/atom.cson @@ -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' diff --git a/src/app/keymaps/editor.cson b/src/app/keymaps/editor.cson index 066385507..8b2e3d8ad 100644 --- a/src/app/keymaps/editor.cson +++ b/src/app/keymaps/editor.cson @@ -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' diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 3978ca696..0a77a8a1d 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -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)