-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add a feature to toggle between panes in the core #10555 #12853
Changes from 2 commits
08a46b3
2f793e7
fc5a114
b092dea
0b63bc7
ce4350b
e099010
77a8f4b
4289bd5
8211931
40586ae
569698f
8823a85
567668a
77ee794
88b333e
717d13e
0848104
954f39c
8e5d581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1658,8 +1658,8 @@ define(function (require, exports, module) { | |
|
||
return result; | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this change as it's only unintentional whitespace modification. |
||
/** | ||
* Setup a ready event to initialize ourself | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,7 @@ define(function (require, exports, module) { | |
ViewUtils = require("utils/ViewUtils"), | ||
ProjectManager = require("project/ProjectManager"), | ||
paneTemplate = require("text!htmlContent/pane.html"); | ||
var KeyBindingManager = brackets.getModule("command/KeyBindingManager"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This var name declaration can be clubbed with the previous one. |
||
|
||
/** | ||
* Internal pane id | ||
|
@@ -208,6 +209,19 @@ define(function (require, exports, module) { | |
return {indexRequested: requestIndex, index: index}; | ||
} | ||
|
||
/** | ||
* Toggle between panes | ||
*/ | ||
function _handleSwitchPane() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire logic of shuffling focus across panes could be in MainViewManager. Pane should contain operations specific to creation, state mutation and handling other things inside a Pane. As this operation is a user requested focus preemption, it could be at a higher level above Panes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will try moving this function to MainViewManager. Thank you! |
||
var $firstPane = $('#first-pane'), $secondPane = $('#second-pane'); | ||
if($firstPane.hasClass('active-pane')) { | ||
$secondPane.click(); | ||
} | ||
else { | ||
$firstPane.click(); | ||
} | ||
} | ||
|
||
/** | ||
* @typedef {!$el: jQuery, getFile:function():!File, updateLayout:function(forceRefresh:boolean), destroy:function(), getScrollPos:function():?, adjustScrollPos:function(state:Object=, heightDelta:number)=, getViewState:function():?*=, restoreViewState:function(viewState:!*)=, notifyContainerChange:function()=, notifyVisibilityChange:function(boolean)=} View | ||
*/ | ||
|
@@ -385,6 +399,10 @@ define(function (require, exports, module) { | |
break; | ||
} | ||
|
||
// Listen to key Alt-W to toggle between panes | ||
CommandManager.register(Strings.CMD_SPLITVIEW_TOGGLE, Commands.CMD_SPLITVIEW_TOGGLE, _handleSwitchPane); | ||
KeyBindingManager.addBinding(Commands.CMD_SPLITVIEW_TOGGLE, {key: 'Alt-W'}); | ||
|
||
// Listen to document events so we can update ourself | ||
DocumentManager.on(this._makeEventName("fileNameChange"), _.bind(this._handleFileNameChange, this)); | ||
DocumentManager.on(this._makeEventName("pathDeleted"), _.bind(this._handleFileDeleted, this)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this command is for shuffling focus across panes, can we name it accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write it like this?
"CMD_SHUFFLE_FOCUS_ACROSS_PANES" : "Shuffle Focus Across Panes",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petetnt What could be a suitable var name here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like
SWITCH_PANE_FOCUS
? 🚲 🏠edit: changed from
TOGGLE
as it sounds like on/off