From ff80545285fe2843f5d99a08c43e837e5337d9bc Mon Sep 17 00:00:00 2001 From: Ardeshir Javaherchi Date: Sat, 8 Nov 2014 15:03:36 -0800 Subject: [PATCH 1/7] :penguin: Add keymap implementation to reorder tabs in linux --- keymaps/linux.cson | 2 ++ src/pane-element.coffee | 2 ++ src/pane.coffee | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/keymaps/linux.cson b/keymaps/linux.cson index d372f18a2..31c8b7314 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-to-left' + 'ctrl-shift-pagedown': 'pane:move-item-to-right' 'F11': 'window:toggle-full-screen' # Sublime Parity diff --git a/src/pane-element.coffee b/src/pane-element.coffee index e6819f9c1..4703965ab 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-to-right': -> @getModel().moveItemToRight() + 'pane:move-item-to-left': -> @getModel().moveItemToLeft() '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..98811dee4 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. + moveItemToRight: -> + index = @getActiveItemIndex() + rightItemIndex = index + 1 + @moveItem(@getActiveItem(), rightItemIndex) unless rightItemIndex > @items.length - 1 + + # Public: Move the active tab to the left + moveItemToLeft: -> + index = @getActiveItemIndex() + leftItemIndex = index - 1 + @moveItem(@getActiveItem(), leftItemIndex) unless leftItemIndex < 0 + # Public: Get the index of the active item. # # Returns a {Number}. From a0e4d8b582307d9bb3ca1a6db33b4eaf1b9ec341 Mon Sep 17 00:00:00 2001 From: Ardeshir Javaherchi Date: Sat, 8 Nov 2014 16:35:24 -0800 Subject: [PATCH 2/7] :white_check_mark: Add test for reordering tabs in linux --- spec/pane-spec.coffee | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 529176040..4cdc8dbd7 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -146,6 +146,22 @@ describe "Pane", -> pane.activateNextItem() expect(pane.getActiveItem()).toBe item1 + describe "::moveItemToRight() and ::moveItemToLeft()", -> + it "moves the active item to the right/left item, without looping around at either end", -> + pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C")]) + [item1, item2, item3] = pane.getItems() + + expect(pane.getActiveItem()).toBe item1 + pane.moveItemToLeft() + expect(pane.getItems()).toEqual [item1, item2, item3] + + pane.moveItemToRight() + expect(pane.getItems()).toEqual [item2, item1, item3] + + pane.moveItemToRight() + pane.moveItemToRight() + expect(pane.getItems()).toEqual [item2, item3, item1] + describe "::activateItemAtIndex(index)", -> it "activates the item at the given index", -> pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C")]) From 5e3b88f42da04c969352e14434f651b798eb90e2 Mon Sep 17 00:00:00 2001 From: Ardeshir Javaherchi Date: Sun, 9 Nov 2014 12:14:08 -0800 Subject: [PATCH 3/7] Add another test for moveItemToLeft --- spec/pane-spec.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 4cdc8dbd7..17006f291 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -151,16 +151,18 @@ describe "Pane", -> 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.moveItemToLeft() expect(pane.getItems()).toEqual [item1, item2, item3] - pane.moveItemToRight() expect(pane.getItems()).toEqual [item2, item1, item3] - + pane.moveItemToLeft() + expect(pane.getItems()).toEqual [item1, item2, item3] + pane.activateItemAtIndex(2) + expect(pane.getActiveItem()).toBe item3 pane.moveItemToRight() - pane.moveItemToRight() - expect(pane.getItems()).toEqual [item2, item3, item1] + expect(pane.getItems()).toEqual [item1, item2, item3] describe "::activateItemAtIndex(index)", -> it "activates the item at the given index", -> From 6159209d4984085ef34f595e9b6a1bcf564f0564 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 10 Nov 2014 13:28:15 -0800 Subject: [PATCH 4/7] moveItemTo* -> moveItem* --- keymaps/linux.cson | 4 ++-- spec/pane-spec.coffee | 12 ++++++------ src/pane-element.coffee | 4 ++-- src/pane.coffee | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/keymaps/linux.cson b/keymaps/linux.cson index 31c8b7314..89ed896f9 100644 --- a/keymaps/linux.cson +++ b/keymaps/linux.cson @@ -12,8 +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-to-left' - 'ctrl-shift-pagedown': 'pane:move-item-to-right' + 'ctrl-shift-pageup': 'pane:move-item-left' + 'ctrl-shift-pagedown': 'pane:move-item-right' 'F11': 'window:toggle-full-screen' # Sublime Parity diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 17006f291..dc1c5869b 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -146,22 +146,22 @@ describe "Pane", -> pane.activateNextItem() expect(pane.getActiveItem()).toBe item1 - describe "::moveItemToRight() and ::moveItemToLeft()", -> - it "moves the active item to the right/left item, without looping around at either end", -> + fdescribe "::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.moveItemToLeft() + pane.moveItemLeft() expect(pane.getItems()).toEqual [item1, item2, item3] - pane.moveItemToRight() + pane.moveItemRight() expect(pane.getItems()).toEqual [item2, item1, item3] - pane.moveItemToLeft() + pane.moveItemLeft() expect(pane.getItems()).toEqual [item1, item2, item3] pane.activateItemAtIndex(2) expect(pane.getActiveItem()).toBe item3 - pane.moveItemToRight() + pane.moveItemRight() expect(pane.getItems()).toEqual [item1, item2, item3] describe "::activateItemAtIndex(index)", -> diff --git a/src/pane-element.coffee b/src/pane-element.coffee index 4703965ab..417f1089e 100644 --- a/src/pane-element.coffee +++ b/src/pane-element.coffee @@ -119,8 +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-to-right': -> @getModel().moveItemToRight() - 'pane:move-item-to-left': -> @getModel().moveItemToLeft() + '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 98811dee4..8650eab64 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -290,13 +290,13 @@ class Pane extends Model @activateItemAtIndex(@items.length - 1) # Public: Move the active tab to the right. - moveItemToRight: -> + moveItemRight: -> index = @getActiveItemIndex() rightItemIndex = index + 1 @moveItem(@getActiveItem(), rightItemIndex) unless rightItemIndex > @items.length - 1 # Public: Move the active tab to the left - moveItemToLeft: -> + moveItemLeft: -> index = @getActiveItemIndex() leftItemIndex = index - 1 @moveItem(@getActiveItem(), leftItemIndex) unless leftItemIndex < 0 From 1247e40e88fd1dcc1165358f09785fefe786c0ac Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 10 Nov 2014 13:31:12 -0800 Subject: [PATCH 5/7] Add tab-moving key bindings for mac --- keymaps/darwin.cson | 2 ++ 1 file changed, 2 insertions(+) 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' From e21cc17a7b1586df3365976502c7409b0bbf685c Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 10 Nov 2014 13:31:18 -0800 Subject: [PATCH 6/7] Add tab-moving key bindings for windows --- keymaps/win32.cson | 2 ++ 1 file changed, 2 insertions(+) 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 From af052c79a70cb798930b4fe7bc8e0a571a602e13 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 10 Nov 2014 13:32:58 -0800 Subject: [PATCH 7/7] nof --- spec/pane-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index dc1c5869b..87ae5cb27 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -146,7 +146,7 @@ describe "Pane", -> pane.activateNextItem() expect(pane.getActiveItem()).toBe item1 - fdescribe "::moveItemRight() and ::moveItemLeft()", -> + 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()