mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Add focusPreviousPane to pane container
This commit is contained in:
committed by
probablycorey
parent
1bbc9f61e9
commit
a9c74762cc
@@ -39,6 +39,18 @@ describe "PaneContainer", ->
|
||||
container.focusNextPane()
|
||||
expect(pane1.activeItem).toMatchSelector ':focus'
|
||||
|
||||
describe ".focusPreviousPane()", ->
|
||||
it "focuses the pane preceding the focused pane or the last pane if no pane has focus", ->
|
||||
container.attachToDom()
|
||||
container.focusPreviousPane()
|
||||
expect(pane3.activeItem).toMatchSelector ':focus'
|
||||
container.focusPreviousPane()
|
||||
expect(pane2.activeItem).toMatchSelector ':focus'
|
||||
container.focusPreviousPane()
|
||||
expect(pane1.activeItem).toMatchSelector ':focus'
|
||||
container.focusPreviousPane()
|
||||
expect(pane3.activeItem).toMatchSelector ':focus'
|
||||
|
||||
describe ".getActivePane()", ->
|
||||
it "returns the most-recently focused pane", ->
|
||||
focusStealer = $$ -> @div tabindex: -1, "focus stealer"
|
||||
|
||||
@@ -32,6 +32,17 @@ class PaneContainer extends View
|
||||
else
|
||||
false
|
||||
|
||||
focusPreviousPane: ->
|
||||
panes = @getPanes()
|
||||
if panes.length > 1
|
||||
currentIndex = panes.indexOf(@getFocusedPane())
|
||||
previousIndex = currentIndex - 1
|
||||
previousIndex = panes.length - 1 if previousIndex < 0
|
||||
panes[previousIndex].focus()
|
||||
true
|
||||
else
|
||||
false
|
||||
|
||||
makeNextPaneActive: ->
|
||||
panes = @getPanes()
|
||||
currentIndex = panes.indexOf(@getActivePane())
|
||||
|
||||
@@ -53,6 +53,7 @@ class RootView extends View
|
||||
config.set("editor.fontSize", fontSize - 1) if fontSize > 1
|
||||
|
||||
@command 'window:focus-next-pane', => @focusNextPane()
|
||||
@command 'window:focus-previous-pane', => @focusPreviousPane()
|
||||
@command 'window:save-all', => @saveAll()
|
||||
@command 'window:toggle-invisibles', =>
|
||||
config.set("editor.showInvisibles", !config.get("editor.showInvisibles"))
|
||||
@@ -143,6 +144,7 @@ class RootView extends View
|
||||
getActiveView: ->
|
||||
@panes.getActiveView()
|
||||
|
||||
focusPreviousPane: -> @panes.focusPreviousPane()
|
||||
focusNextPane: -> @panes.focusNextPane()
|
||||
getFocusedPane: -> @panes.getFocusedPane()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user