From ef263580df4eeaf36de9f8425737399e866521a8 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:05:29 -0800 Subject: [PATCH 1/7] Replace WorkspaceView:eachPane with WorkspaceView:eachPaneView --- spec/pane-container-view-spec.coffee | 4 ++-- src/pane-container-view.coffee | 2 +- src/workspace-view.coffee | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/pane-container-view-spec.coffee b/spec/pane-container-view-spec.coffee index 28fbd56a6..1b923c329 100644 --- a/spec/pane-container-view-spec.coffee +++ b/spec/pane-container-view-spec.coffee @@ -45,10 +45,10 @@ describe "PaneContainerView", -> expect(container.getFocusedPane()).toBe pane3 expect(container.getActivePane()).toBe pane3 - describe ".eachPane(callback)", -> + describe ".eachPaneView(callback)", -> it "runs the callback with all current and future panes until the subscription is cancelled", -> panes = [] - subscription = container.eachPane (pane) -> panes.push(pane) + subscription = container.eachPaneView (pane) -> panes.push(pane) expect(panes).toEqual [pane1, pane2, pane3] panes = [] diff --git a/src/pane-container-view.coffee b/src/pane-container-view.coffee index 093c3e29d..1710f61ff 100644 --- a/src/pane-container-view.coffee +++ b/src/pane-container-view.coffee @@ -70,7 +70,7 @@ class PaneContainerView extends View paneAtIndex: (index) -> @getPanes()[index] - eachPane: (callback) -> + eachPaneView: (callback) -> callback(pane) for pane in @getPanes() paneAttached = (e) -> callback($(e.target).view()) @on 'pane:attached', paneAttached diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 2128e04c2..4c7ce45c1 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -269,8 +269,8 @@ class WorkspaceView extends View getFocusedPane: -> @panes.getFocusedPane() # Public: Fires a callback on each open {PaneView}. - eachPane: (callback) -> - @panes.eachPane(callback) + eachPaneView: (callback) -> + @panes.eachPaneView(callback) # Public: Returns an Array of all open {PaneView}s. getPanes: -> @@ -290,3 +290,7 @@ class WorkspaceView extends View # Called by SpacePen beforeRemove: -> @model.destroy() + + # Deprecated: + eachPane: (callback) -> + @eachPaneView(callback) From b042dffc2cccf424da85f7e684973e31804ea1b0 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:13:27 -0800 Subject: [PATCH 2/7] Rename Workspace::getPanes to Workspace::getPaneViews --- spec/pane-container-view-spec.coffee | 4 ++-- spec/workspace-view-spec.coffee | 4 ++-- src/pane-container-view.coffee | 15 +++++++++------ src/pane-view.coffee | 2 +- src/workspace-view.coffee | 8 ++++++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/spec/pane-container-view-spec.coffee b/spec/pane-container-view-spec.coffee index 1b923c329..c382c5f8f 100644 --- a/spec/pane-container-view-spec.coffee +++ b/spec/pane-container-view-spec.coffee @@ -66,7 +66,7 @@ describe "PaneContainerView", -> container.saveAll() - for pane in container.getPanes() + for pane in container.getPaneViews() for item in pane.getItems() expect(item.saved).toBeTruthy() @@ -255,7 +255,7 @@ describe "PaneContainerView", -> describe ".focusPreviousPane()", -> it "focuses the pane preceding the focused pane or the last pane if no pane has focus", -> container.attachToDom() - container.getPanes()[0].focus() # activate first pane + container.getPaneViews()[0].focus() # activate first pane container.focusPreviousPane() expect(pane3.activeItem).toMatchSelector ':focus' diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index d13ca3323..245666c23 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -36,12 +36,12 @@ describe "WorkspaceView", -> editorView1 = atom.workspaceView.getActiveView() buffer = editorView1.getEditor().getBuffer() editorView1.splitRight() - expect(atom.workspaceView.getActivePane()).toBe atom.workspaceView.getPanes()[1] + expect(atom.workspaceView.getActivePane()).toBe atom.workspaceView.getPaneViews()[1] simulateReload() expect(atom.workspaceView.getEditorViews().length).toBe 2 - expect(atom.workspaceView.getActivePane()).toBe atom.workspaceView.getPanes()[1] + expect(atom.workspaceView.getActivePane()).toBe atom.workspaceView.getPaneViews()[1] expect(atom.workspaceView.title).toBe "untitled - #{atom.project.getPath()}" describe "when there are open editors", -> diff --git a/src/pane-container-view.coffee b/src/pane-container-view.coffee index 1710f61ff..5e0378f6f 100644 --- a/src/pane-container-view.coffee +++ b/src/pane-container-view.coffee @@ -54,24 +54,24 @@ class PaneContainerView extends View confirmClose: -> saved = true - for pane in @getPanes() + for pane in @getPaneViews() for item in pane.getItems() if not pane.promptToSaveItem(item) saved = false break saved - getPanes: -> + getPaneViews: -> @find('.pane').views() indexOfPane: (pane) -> - @getPanes().indexOf(pane.view()) + @getPaneViews().indexOf(pane.view()) paneAtIndex: (index) -> - @getPanes()[index] + @getPaneViews()[index] eachPaneView: (callback) -> - callback(pane) for pane in @getPanes() + callback(pane) for pane in @getPaneViews() paneAttached = (e) -> callback($(e.target).view()) @on 'pane:attached', paneAttached off: => @off 'pane:attached', paneAttached @@ -117,7 +117,7 @@ class PaneContainerView extends View pane = @getActivePane() box = @boundingBoxForPane(pane) - panes = @getPanes() + panes = @getPaneViews() .filter (otherPane) => otherBox = @boundingBoxForPane(otherPane) switch direction @@ -143,3 +143,6 @@ class PaneContainerView extends View right: {x: boundingBox.right, y: boundingBox.top} top: {x: boundingBox.left, y: boundingBox.top} bottom: {x: boundingBox.left, y: boundingBox.bottom} + + getPanes: -> + @getPaneViews() diff --git a/src/pane-view.coffee b/src/pane-view.coffee index 09cc2a62b..59fb98074 100644 --- a/src/pane-view.coffee +++ b/src/pane-view.coffee @@ -117,7 +117,7 @@ class PaneView extends View # Public: Returns the next pane, ordered by creation. getNextPane: -> - panes = @container?.getPanes() + panes = @container?.getPaneViews() return unless panes.length > 1 nextIndex = (panes.indexOf(this) + 1) % panes.length panes[nextIndex] diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 4c7ce45c1..d0b5e55a9 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -272,8 +272,8 @@ class WorkspaceView extends View eachPaneView: (callback) -> @panes.eachPaneView(callback) - # Public: Returns an Array of all open {PaneView}s. - getPanes: -> + # Returns an Array of all open {PaneView}s. + getPaneViews: -> @panes.getPanes() # Public: Return the id of the given a {PaneView} @@ -294,3 +294,7 @@ class WorkspaceView extends View # Deprecated: eachPane: (callback) -> @eachPaneView(callback) + + # Deprecated: + getPanes: -> + @getPaneViews() From 245ad7a3564ae41f8f0f1fa178194076d51d5180 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:31:19 -0800 Subject: [PATCH 3/7] Rename pane focusing methods on Workspace --- spec/pane-container-view-spec.coffee | 44 ++++++++++++++-------------- src/pane-container-view.coffee | 12 ++++---- src/workspace-view.coffee | 24 +++++++-------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/spec/pane-container-view-spec.coffee b/spec/pane-container-view-spec.coffee index c382c5f8f..149658b0e 100644 --- a/spec/pane-container-view-spec.coffee +++ b/spec/pane-container-view-spec.coffee @@ -240,30 +240,30 @@ describe "PaneContainerView", -> pane2.remove() expect(activeItemChangedHandler).not.toHaveBeenCalled() - describe ".focusNextPane()", -> + describe ".focusNextPaneView()", -> it "focuses the pane following the focused pane or the first pane if no pane has focus", -> container.attachToDom() - container.focusNextPane() + container.focusNextPaneView() expect(pane1.activeItem).toMatchSelector ':focus' - container.focusNextPane() + container.focusNextPaneView() expect(pane2.activeItem).toMatchSelector ':focus' - container.focusNextPane() + container.focusNextPaneView() expect(pane3.activeItem).toMatchSelector ':focus' - container.focusNextPane() + container.focusNextPaneView() expect(pane1.activeItem).toMatchSelector ':focus' - describe ".focusPreviousPane()", -> + describe ".focusPreviousPaneView()", -> it "focuses the pane preceding the focused pane or the last pane if no pane has focus", -> container.attachToDom() container.getPaneViews()[0].focus() # activate first pane - container.focusPreviousPane() + container.focusPreviousPaneView() expect(pane3.activeItem).toMatchSelector ':focus' - container.focusPreviousPane() + container.focusPreviousPaneView() expect(pane2.activeItem).toMatchSelector ':focus' - container.focusPreviousPane() + container.focusPreviousPaneView() expect(pane1.activeItem).toMatchSelector ':focus' - container.focusPreviousPane() + container.focusPreviousPaneView() expect(pane3.activeItem).toMatchSelector ':focus' describe "changing focus directionally between panes", -> @@ -300,54 +300,54 @@ describe "PaneContainerView", -> container.width(400) container.attachToDom() - describe ".focusPaneAbove()", -> + describe ".focusPaneViewAbove()", -> describe "when there are multiple rows above the focused pane", -> it "focuses up to the adjacent row", -> pane8.focus() - container.focusPaneAbove() + container.focusPaneViewAbove() expect(pane5.activeItem).toMatchSelector ':focus' describe "when there are no rows above the focused pane", -> it "keeps the current pane focused", -> pane2.focus() - container.focusPaneAbove() + container.focusPaneViewAbove() expect(pane2.activeItem).toMatchSelector ':focus' - describe ".focusPaneBelow()", -> + describe ".focusPaneViewBelow()", -> describe "when there are multiple rows below the focused pane", -> it "focuses down to the adjacent row", -> pane2.focus() - container.focusPaneBelow() + container.focusPaneViewBelow() expect(pane5.activeItem).toMatchSelector ':focus' describe "when there are no rows below the focused pane", -> it "keeps the current pane focused", -> pane8.focus() - container.focusPaneBelow() + container.focusPaneViewBelow() expect(pane8.activeItem).toMatchSelector ':focus' - describe ".focusPaneOnLeft()", -> + describe ".focusPaneViewOnLeft()", -> describe "when there are multiple columns to the left of the focused pane", -> it "focuses left to the adjacent column", -> pane6.focus() - container.focusPaneOnLeft() + container.focusPaneViewOnLeft() expect(pane5.activeItem).toMatchSelector ':focus' describe "when there are no columns to the left of the focused pane", -> it "keeps the current pane focused", -> pane4.focus() - container.focusPaneOnLeft() + container.focusPaneViewOnLeft() expect(pane4.activeItem).toMatchSelector ':focus' - describe ".focusPaneOnRight()", -> + describe ".focusPaneViewOnRight()", -> describe "when there are multiple columns to the right of the focused pane", -> it "focuses right to the adjacent column", -> pane4.focus() - container.focusPaneOnRight() + container.focusPaneViewOnRight() expect(pane5.activeItem).toMatchSelector ':focus' describe "when there are no columns to the right of the focused pane", -> it "keeps the current pane focused", -> pane6.focus() - container.focusPaneOnRight() + container.focusPaneViewOnRight() expect(pane6.activeItem).toMatchSelector ':focus' diff --git a/src/pane-container-view.coffee b/src/pane-container-view.coffee index 5e0378f6f..c14b6ac69 100644 --- a/src/pane-container-view.coffee +++ b/src/pane-container-view.coffee @@ -91,22 +91,22 @@ class PaneContainerView extends View paneForUri: (uri) -> @viewForModel(@model.paneForUri(uri)) - focusNextPane: -> + focusNextPaneView: -> @model.activateNextPane() - focusPreviousPane: -> + focusPreviousPaneView: -> @model.activatePreviousPane() - focusPaneAbove: -> + focusPaneViewAbove: -> @nearestPaneInDirection('above')?.focus() - focusPaneBelow: -> + focusPaneViewBelow: -> @nearestPaneInDirection('below')?.focus() - focusPaneOnLeft: -> + focusPaneViewOnLeft: -> @nearestPaneInDirection('left')?.focus() - focusPaneOnRight: -> + focusPaneViewOnRight: -> @nearestPaneInDirection('right')?.focus() nearestPaneInDirection: (direction) -> diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index d0b5e55a9..ae5915b67 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -119,12 +119,12 @@ class WorkspaceView extends View @command 'window:decrease-font-size', => @decreaseFontSize() @command 'window:reset-font-size', => @model.resetFontSize() - @command 'window:focus-next-pane', => @focusNextPane() - @command 'window:focus-previous-pane', => @focusPreviousPane() - @command 'window:focus-pane-above', => @focusPaneAbove() - @command 'window:focus-pane-below', => @focusPaneBelow() - @command 'window:focus-pane-on-left', => @focusPaneOnLeft() - @command 'window:focus-pane-on-right', => @focusPaneOnRight() + @command 'window:focus-next-pane', => @focusNextPaneView() + @command 'window:focus-previous-pane', => @focusPreviousPaneView() + @command 'window:focus-pane-above', => @focusPaneViewAbove() + @command 'window:focus-pane-below', => @focusPaneViewBelow() + @command 'window:focus-pane-on-left', => @focusPaneViewOnLeft() + @command 'window:focus-pane-on-right', => @focusPaneViewOnRight() @command 'window:save-all', => @saveAll() @command 'window:toggle-invisibles', => atom.config.toggle("editor.showInvisibles") @@ -246,22 +246,22 @@ class WorkspaceView extends View @panes.getActiveView() # Public: Focuses the previous pane by id. - focusPreviousPane: -> @model.activatePreviousPane() + focusPreviousPaneView: -> @model.activatePreviousPane() # Public: Focuses the next pane by id. - focusNextPane: -> @model.activateNextPane() + focusNextPaneView: -> @model.activateNextPane() # Public: Focuses the pane directly above the active pane. - focusPaneAbove: -> @panes.focusPaneAbove() + focusPaneViewAbove: -> @panes.focusPaneViewAbove() # Public: Focuses the pane directly below the active pane. - focusPaneBelow: -> @panes.focusPaneBelow() + focusPaneViewBelow: -> @panes.focusPaneViewBelow() # Public: Focuses the pane directly to the left of the active pane. - focusPaneOnLeft: -> @panes.focusPaneOnLeft() + focusPaneViewOnLeft: -> @panes.focusPaneViewOnLeft() # Public: Focuses the pane directly to the right of the active pane. - focusPaneOnRight: -> @panes.focusPaneOnRight() + focusPaneViewOnRight: -> @panes.focusPaneViewOnRight() # Public: # From 98a25ca5e309b8bb6823f992278ebebda2828686 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:32:32 -0800 Subject: [PATCH 4/7] :lipstick: --- src/workspace-view.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index ae5915b67..aa40189a8 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -233,10 +233,6 @@ class WorkspaceView extends View getActivePaneView: -> @panes.getActivePane() - # Deprecated: Returns the currently focused {PaneView}. - getActivePane: -> - @getActivePaneView() - # Public: Returns the currently focused item from within the focused {PaneView} getActivePaneItem: -> @model.activePaneItem @@ -291,10 +287,14 @@ class WorkspaceView extends View beforeRemove: -> @model.destroy() - # Deprecated: + # Deprecated eachPane: (callback) -> @eachPaneView(callback) - # Deprecated: + # Deprecated getPanes: -> @getPaneViews() + + # Deprecated + getActivePane: -> + @getActivePaneView() From e67fb86084d9a6d86e3bd43938d0058d880a628a Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:33:57 -0800 Subject: [PATCH 5/7] Remove Workspace::getFocusedPane --- src/workspace-view.coffee | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index aa40189a8..a4eb9c422 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -259,11 +259,6 @@ class WorkspaceView extends View # Public: Focuses the pane directly to the right of the active pane. focusPaneViewOnRight: -> @panes.focusPaneViewOnRight() - # Public: - # - # FIXME: Difference between active and focused pane? - getFocusedPane: -> @panes.getFocusedPane() - # Public: Fires a callback on each open {PaneView}. eachPaneView: (callback) -> @panes.eachPaneView(callback) From 99774d74170b92dd98c5030ebef757bc2a8136fa Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:37:36 -0800 Subject: [PATCH 6/7] Add comment to PaneContainer::indexOfPane --- src/pane-container-view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pane-container-view.coffee b/src/pane-container-view.coffee index c14b6ac69..2ed53b19b 100644 --- a/src/pane-container-view.coffee +++ b/src/pane-container-view.coffee @@ -144,5 +144,6 @@ class PaneContainerView extends View top: {x: boundingBox.left, y: boundingBox.top} bottom: {x: boundingBox.left, y: boundingBox.bottom} + # Deprecated getPanes: -> @getPaneViews() From 69396922db31d385d3aeab3c4a36b5008d35a7cd Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 18 Feb 2014 15:37:51 -0800 Subject: [PATCH 7/7] Remove WorkspaceView::indexOfPane --- src/workspace-view.coffee | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index a4eb9c422..bb7779b3e 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -267,10 +267,6 @@ class WorkspaceView extends View getPaneViews: -> @panes.getPanes() - # Public: Return the id of the given a {PaneView} - indexOfPane: (pane) -> - @panes.indexOfPane(pane) - # Public: Fires a callback on each open {EditorView}. eachEditorView: (callback) -> callback(editor) for editor in @getEditorViews()