diff --git a/keymaps/darwin.cson b/keymaps/darwin.cson index c6975f1be..7d4bf82f3 100644 --- a/keymaps/darwin.cson +++ b/keymaps/darwin.cson @@ -29,6 +29,8 @@ 'ctrl-alt-cmd-l': 'window:reload' 'alt-cmd-i': 'window:toggle-dev-tools' 'cmd-alt-ctrl-p': 'window:run-package-specs' + 'ctrl-shift-left': 'pane:move-item-left' + 'ctrl-shift-right': 'pane:move-item-right' # Sublime Parity 'cmd-,': 'application:show-settings' diff --git a/keymaps/linux.cson b/keymaps/linux.cson index d372f18a2..89ed896f9 100644 --- a/keymaps/linux.cson +++ b/keymaps/linux.cson @@ -12,6 +12,8 @@ 'ctrl-alt-s': 'application:run-all-specs' 'ctrl-alt-o': 'application:open-dev' 'ctrl-shift-o': 'application:open-folder' + 'ctrl-shift-pageup': 'pane:move-item-left' + 'ctrl-shift-pagedown': 'pane:move-item-right' 'F11': 'window:toggle-full-screen' # Sublime Parity diff --git a/keymaps/win32.cson b/keymaps/win32.cson index 788640979..a98440d0c 100644 --- a/keymaps/win32.cson +++ b/keymaps/win32.cson @@ -16,6 +16,8 @@ 'ctrl-alt-s': 'application:run-all-specs' 'ctrl-alt-o': 'application:open-dev' 'ctrl-shift-o': 'application:open-folder' + 'ctrl-shift-left': 'pane:move-item-left' + 'ctrl-shift-right': 'pane:move-item-right' 'F11': 'window:toggle-full-screen' # Sublime Parity diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 529176040..87ae5cb27 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -146,6 +146,24 @@ describe "Pane", -> pane.activateNextItem() expect(pane.getActiveItem()).toBe item1 + describe "::moveItemRight() and ::moveItemLeft()", -> + it "moves the active item to the right and left, without looping around at either end", -> + pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C")]) + [item1, item2, item3] = pane.getItems() + + pane.activateItemAtIndex(0) + expect(pane.getActiveItem()).toBe item1 + pane.moveItemLeft() + expect(pane.getItems()).toEqual [item1, item2, item3] + pane.moveItemRight() + expect(pane.getItems()).toEqual [item2, item1, item3] + pane.moveItemLeft() + expect(pane.getItems()).toEqual [item1, item2, item3] + pane.activateItemAtIndex(2) + expect(pane.getActiveItem()).toBe item3 + pane.moveItemRight() + expect(pane.getItems()).toEqual [item1, item2, item3] + describe "::activateItemAtIndex(index)", -> it "activates the item at the given index", -> pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C")]) diff --git a/src/pane-element.coffee b/src/pane-element.coffee index e6819f9c1..417f1089e 100644 --- a/src/pane-element.coffee +++ b/src/pane-element.coffee @@ -119,6 +119,8 @@ atom.commands.add 'atom-pane', 'pane:show-item-7': -> @getModel().activateItemAtIndex(6) 'pane:show-item-8': -> @getModel().activateItemAtIndex(7) 'pane:show-item-9': -> @getModel().activateItemAtIndex(8) + 'pane:move-item-right': -> @getModel().moveItemRight() + 'pane:move-item-left': -> @getModel().moveItemLeft() 'pane:split-left': -> @getModel().splitLeft(copyActiveItem: true) 'pane:split-right': -> @getModel().splitRight(copyActiveItem: true) 'pane:split-up': -> @getModel().splitUp(copyActiveItem: true) diff --git a/src/pane.coffee b/src/pane.coffee index c67d51d25..8650eab64 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -289,6 +289,18 @@ class Pane extends Model else @activateItemAtIndex(@items.length - 1) + # Public: Move the active tab to the right. + moveItemRight: -> + index = @getActiveItemIndex() + rightItemIndex = index + 1 + @moveItem(@getActiveItem(), rightItemIndex) unless rightItemIndex > @items.length - 1 + + # Public: Move the active tab to the left + moveItemLeft: -> + index = @getActiveItemIndex() + leftItemIndex = index - 1 + @moveItem(@getActiveItem(), leftItemIndex) unless leftItemIndex < 0 + # Public: Get the index of the active item. # # Returns a {Number}.