MainViewManager
Import :
const MainViewManager = brackets.getModule("view/MainViewManager")
_
MainViewManager manages the arrangement of all open panes as well as provides the controller logic behind all views in the MainView (e.g. ensuring that a file doesn't appear in 2 lists)
Each pane contains one or more views wich are created by a view factory and inserted into a pane list. There may be several panes managed by the MainViewManager with each pane containing a list of views. The panes are always visible and the layout is determined by the MainViewManager and the user.
Currently we support only 2 panes.
All of the WorkingSet APIs take a paneId Argument. This can be an actual pane Id, ALL_PANES (in most cases) or ACTIVE_PANE. ALL_PANES may not be supported for some APIs. See the API for details.
This module dispatches several events:
- activePaneChange - When the active pane changes. There will always be an active pane. (e, newPaneId:string, oldPaneId:string)
- currentFileChange -- When the user has switched to another pane, file, document. When the user closes a view and there are no other views to show the current file will be null. (e, newFile:File, newPaneId:string, oldFile:File, oldPaneId:string)
- paneLayoutChange -- When Orientation changes. (e, orientation:string)
- paneCreate -- When a pane is created (e, paneId:string)
- paneDestroy -- When a pane is destroyed (e, paneId:string)
To listen for working set changes, you must listen to all of these events:
- workingSetAdd -- When a file is added to the working set (e, fileAdded:File, index:number, paneId:string)
- workingSetAddList -- When multiple files are added to the working set (e, fileAdded:Array."File", paneId:string)
- workingSetMove - When a File has moved to a different working set (e, File:FILE, sourcePaneId:string, destinationPaneId:string)
- workingSetRemove -- When a file is removed from the working set (e, fileRemoved:File, suppressRedraw:boolean, paneId:string)
- workingSetRemoveList -- When multiple files are removed from the working set (e, filesRemoved:Array."File", paneId:string)
- workingSetSort -- When a pane's view array is reordered without additions or removals. (e, paneId:string)
- workingSetUpdate -- When changes happen due to system events such as a file being deleted. listeners should discard all working set info and rebuilt it from the pane by calling getWorkingSet() (e, paneId:string)
- _workingSetDisableAutoSort -- When the working set is reordered by manually dragging a file. (e, paneId:string) For Internal Use Only.
To listen for events, do something like this: (see EventDispatcher for details on this pattern)
MainViewManager.on("eventname", handler);
Kind: global variable
EVENT_CURRENT_FILE_CHANGE : string
Event current file change
Kind: global constant
ALL_PANES
Special paneId shortcut that can be used to specify that all panes should be targeted by the API. Not all APIs support this constnant. Check the API documentation before use.
Kind: global constant
ACTIVE_PANE
Special paneId shortcut that can be used to specify that the API should target the focused pane only. All APIs support this shortcut.
Kind: global constant
isExclusiveToPane(File) ⇒ Object
Checks whether a file is listed exclusively in the provided pane
Kind: global function
Param | Type | Description |
---|---|---|
File | File | the file |
getActivePaneId() ⇒ string
Retrieves the currently active Pane Id
Kind: global function
Returns: string
- Active Pane's ID.
focusActivePane()
Focuses the current pane. If the current pane has a current view, then the pane will focus the view.
Kind: global function
setActivePaneId(paneId)
Switch active pane to the specified pane id (or ACTIVE_PANE/ALL_PANES, in which case this call does nothing).
Kind: global function
Param | Type | Description |
---|---|---|
paneId | string | the id of the pane to activate |
getCurrentlyViewedFile(paneId) ⇒ File
Retrieves the currently viewed file of the specified paneId
Kind: global function
Returns: File
- File object of the currently viewed file, or null if there isn't one or there's no such pane
Param | Type | Description |
---|---|---|
paneId | string | the id of the pane in which to retrieve the currently viewed file |
getCurrentlyViewedEditor(paneId) ⇒ Editor
Retrieves the currently viewed editor of the specified paneId
Kind: global function
Returns: Editor
- currently editor, or null if there isn't one or there's no such pane
Param | Type | Description |
---|---|---|
paneId | string | the id of the pane in which to retrieve the currently viewed editor |
getAllViewedEditors() ⇒ Object
Gets an array of editors open in panes with their pane IDs. Can return an empty array if no editors are open.
Kind: global function
Returns: Object
- An array of objects, each containing an editor and its corresponding pane ID.
getCurrentlyViewedPath(paneId) ⇒ string
Retrieves the currently viewed path of the pane specified by paneId
Kind: global function
Returns: string
- the path of the currently viewed file or null if there isn't one
Param | Type | Description |
---|---|---|
paneId | string | the id of the pane in which to retrieve the currently viewed path |
cacheScrollState(paneId)
Caches the specified pane's current scroll state If there was already cached state for the specified pane, it is discarded and overwritten
Kind: global function
Param | Type | Description |
---|---|---|
paneId | string | id of the pane in which to cache the scroll state, ALL_PANES or ACTIVE_PANE |