UNPKG

4.37 kBTypeScriptView Raw
1import { Disposable, Pane, PaneItemObservedEvent } from '../index';
2
3/** A container at the edges of the editor window capable of holding items. */
4export interface Dock {
5 // Methods
6 /** Show the dock and focus its active Pane. */
7 activate(): void;
8
9 /** Show the dock without focusing it. */
10 show(): void;
11
12 /**
13 * Hide the dock and activate the WorkspaceCenter if the dock was was previously
14 * focused.
15 */
16 hide(): void;
17
18 /**
19 * Toggle the dock's visibility without changing the Workspace's active pane
20 * container.
21 */
22 toggle(): void;
23
24 /** Check if the dock is visible. */
25 isVisible(): boolean;
26
27 // Event Subscription
28 /** Invoke the given callback when the visibility of the dock changes. */
29 onDidChangeVisible(callback: (visible: boolean) => void): Disposable;
30
31 /**
32 * Invoke the given callback with the current and all future visibilities of
33 * the dock.
34 */
35 observeVisible(callback: (visible: boolean) => void): Disposable;
36
37 /** Invoke the given callback with all current and future panes items in the dock. */
38 observePaneItems(callback: (item: object) => void): Disposable;
39
40 /**
41 * Invoke the given callback when the active pane item changes.
42 *
43 * Because observers are invoked synchronously, it's important not to perform any
44 * expensive operations via this method. Consider ::onDidStopChangingActivePaneItem
45 * to delay operations until after changes stop occurring.
46 */
47 onDidChangeActivePaneItem(callback: (item: object) => void): Disposable;
48
49 /** Invoke the given callback when the active pane item stops changing. */
50 onDidStopChangingActivePaneItem(callback: (item: object) => void): Disposable;
51
52 /**
53 * Invoke the given callback with the current active pane item and with all future
54 * active pane items in the dock.
55 */
56 observeActivePaneItem(callback: (item: object) => void): Disposable;
57
58 /** Invoke the given callback when a pane is added to the dock. */
59 onDidAddPane(callback: (event: { pane: Pane }) => void): Disposable;
60
61 /** Invoke the given callback before a pane is destroyed in the dock. */
62 onWillDestroyPane(callback: (event: { pane: Pane }) => void): Disposable;
63
64 /** Invoke the given callback when a pane is destroyed in the dock. */
65 onDidDestroyPane(callback: (event: { pane: Pane }) => void): Disposable;
66
67 /** Invoke the given callback with all current and future panes in the dock. */
68 observePanes(callback: (pane: Pane) => void): Disposable;
69
70 /** Invoke the given callback when the active pane changes. */
71 onDidChangeActivePane(callback: (pane: Pane) => void): Disposable;
72
73 /**
74 * Invoke the given callback with the current active pane and when the active
75 * pane changes.
76 */
77 observeActivePane(callback: (pane: Pane) => void): Disposable;
78
79 /** Invoke the given callback when a pane item is added to the dock. */
80 onDidAddPaneItem(callback: (event: PaneItemObservedEvent) => void): Disposable;
81
82 /**
83 * Invoke the given callback when a pane item is about to be destroyed, before the user is
84 * prompted to save it.
85 * @param callback The function to be called before pane items are destroyed.
86 * If this function returns a Promise, then the item will not be destroyed
87 * until the promise resolves.
88 */
89 onWillDestroyPaneItem(callback: (event: PaneItemObservedEvent) => void | Promise<void>): Disposable;
90
91 /** Invoke the given callback when a pane item is destroyed. */
92 onDidDestroyPaneItem(callback: (event: PaneItemObservedEvent) => void): Disposable;
93
94 /**
95 * Invoke the given callback when the hovered state of the dock changes.
96 * @param hovered Is the dock now hovered?
97 */
98 onDidChangeHovered(callback: (hovered: boolean) => void): Disposable;
99
100 // Pane Items
101 /** Get all pane items in the dock. */
102 getPaneItems(): object[];
103
104 /** Get the active Pane's active item. */
105 getActivePaneItem(): object;
106
107 // Panes
108 /** Returns an Array of Panes. */
109 getPanes(): Pane[];
110
111 /** Get the active Pane. */
112 getActivePane(): Pane;
113
114 /** Make the next pane active. */
115 activateNextPane(): boolean;
116
117 /** Make the previous pane active. */
118 activatePreviousPane(): boolean;
119}