UNPKG

7.68 kBTypeScriptView Raw
1import { Disposable } from "../index";
2
3/** A container for presenting content in the center of the workspace. */
4export interface Pane {
5 // Event Subscription
6 /** Invoke the given callback when the pane resizes. */
7 onDidChangeFlexScale(callback: (flexScale: number) => void): Disposable;
8
9 /** Invoke the given callback with the current and future values of ::getFlexScale. */
10 observeFlexScale(callback: (flexScale: number) => void): Disposable;
11
12 /** Invoke the given callback when the pane is activated. */
13 onDidActivate(callback: () => void): Disposable;
14
15 /** Invoke the given callback before the pane is destroyed. */
16 onWillDestroy(callback: () => void): Disposable;
17
18 /** Invoke the given callback when the pane is destroyed. */
19 onDidDestroy(callback: () => void): Disposable;
20
21 /** Invoke the given callback when the value of the ::isActive property changes. */
22 onDidChangeActive(callback: (active: boolean) => void): Disposable;
23
24 /**
25 * Invoke the given callback with the current and future values of the ::isActive
26 * property.
27 */
28 observeActive(callback: (active: boolean) => void): Disposable;
29
30 /** Invoke the given callback when an item is added to the pane. */
31 onDidAddItem(callback: (event: PaneListItemShiftedEvent) => void): Disposable;
32
33 /** Invoke the given callback when an item is removed from the pane. */
34 onDidRemoveItem(callback: (event: PaneListItemShiftedEvent) => void): Disposable;
35
36 /** Invoke the given callback before an item is removed from the pane. */
37 onWillRemoveItem(callback: (event: PaneListItemShiftedEvent) => void): Disposable;
38
39 /** Invoke the given callback when an item is moved within the pane. */
40 onDidMoveItem(callback: (event: PaneItemMovedEvent) => void): Disposable;
41
42 /** Invoke the given callback with all current and future items. */
43 observeItems(callback: (item: object) => void): Disposable;
44
45 /** Invoke the given callback when the value of ::getActiveItem changes. */
46 onDidChangeActiveItem(callback: (activeItem: object) => void): Disposable;
47
48 /**
49 * Invoke the given callback when ::activateNextRecentlyUsedItem has been called,
50 * either initiating or continuing a forward MRU traversal of pane items.
51 */
52 onChooseNextMRUItem(callback: (nextRecentlyUsedItem: object) => void): Disposable;
53
54 /**
55 * Invoke the given callback when ::activatePreviousRecentlyUsedItem has been called,
56 * either initiating or continuing a reverse MRU traversal of pane items.
57 */
58 onChooseLastMRUItem(callback: (previousRecentlyUsedItem: object) => void): Disposable;
59
60 /**
61 * Invoke the given callback when ::moveActiveItemToTopOfStack has been called,
62 * terminating an MRU traversal of pane items and moving the current active item
63 * to the top of the stack. Typically bound to a modifier (e.g. CTRL) key up event.
64 */
65 onDoneChoosingMRUItem(callback: () => void): Disposable;
66
67 /** Invoke the given callback with the current and future values of ::getActiveItem. */
68 observeActiveItem(callback: (activeItem: object) => void): Disposable;
69
70 /** Invoke the given callback before items are destroyed. */
71 onWillDestroyItem(callback: (event: PaneListItemShiftedEvent) => void): Disposable;
72
73 // Items
74 /** Get the items in this pane. */
75 getItems(): object[];
76
77 /** Get the active pane item in this pane. */
78 getActiveItem(): object;
79
80 /** Return the item at the given index. */
81 itemAtIndex(index: number): object | undefined;
82
83 /** Makes the next item active. */
84 activateNextItem(): void;
85
86 /** Makes the previous item active. */
87 activatePreviousItem(): void;
88
89 /** Move the active tab to the right. */
90 moveItemRight(): void;
91
92 /** Move the active tab to the left. */
93 moveItemLeft(): void;
94
95 /** Get the index of the active item. */
96 getActiveItemIndex(): number;
97
98 /** Activate the item at the given index. */
99 activateItemAtIndex(index: number): void;
100
101 /** Make the given item active, causing it to be displayed by the pane's view. */
102 activateItem(item: object, options?: { pending: boolean }): void;
103
104 /** Add the given item to the pane. */
105 addItem(item: object, options?: { index?: number | undefined; pending?: boolean | undefined }): object;
106
107 /** Add the given items to the pane. */
108 addItems(items: object[], index?: number): object[];
109
110 /** Move the given item to the given index. */
111 moveItem(item: object, index: number): void;
112
113 /** Move the given item to the given index on another pane. */
114 moveItemToPane(item: object, pane: Pane, index: number): void;
115
116 /** Destroy the active item and activate the next item. */
117 destroyActiveItem(): Promise<boolean>;
118
119 /** Destroy the given item. */
120 destroyItem(item: object, force?: boolean): Promise<boolean>;
121
122 /** Destroy all items. */
123 destroyItems(): Promise<boolean[]>;
124
125 /** Destroy all items except for the active item. */
126 destroyInactiveItems(): Promise<boolean[]>;
127
128 /** Save the active item. */
129 saveActiveItem<T = void>(nextAction?: (error?: Error) => T): Promise<T> | undefined;
130
131 /**
132 * Prompt the user for a location and save the active item with the path
133 * they select.
134 */
135 saveActiveItemAs<T = void>(nextAction?: (error?: Error) => T): Promise<T> | undefined;
136
137 /** Save the given item. */
138 saveItem<T = void>(item: object, nextAction?: (error?: Error) => T): Promise<T> | undefined;
139
140 /**
141 * Prompt the user for a location and save the active item with the path
142 * they select.
143 */
144 saveItemAs<T = void>(item: object, nextAction?: (error?: Error) => T): Promise<T> | undefined;
145
146 /** Save all items. */
147 saveItems(): void;
148
149 /** Return the first item that matches the given URI or undefined if none exists. */
150 itemForURI(uri: string): object | undefined;
151
152 /** Activate the first item that matches the given URI. */
153 activateItemForURI(uri: string): boolean;
154
155 // Lifecycle
156 /** Determine whether the pane is active. */
157 isActive(): boolean;
158
159 /** Makes this pane the active pane, causing it to gain focus. */
160 activate(): void;
161
162 /** Close the pane and destroy all its items. */
163 destroy(): void;
164
165 /** Determine whether this pane has been destroyed. */
166 isDestroyed(): boolean;
167
168 // Splitting
169 /** Create a new pane to the left of this pane. */
170 splitLeft(params?: { items?: object[] | undefined; copyActiveItem?: boolean | undefined }): Pane;
171
172 /** Create a new pane to the right of this pane. */
173 splitRight(params?: { items?: object[] | undefined; copyActiveItem?: boolean | undefined }): Pane;
174
175 /** Creates a new pane above the receiver. */
176 splitUp(params?: { items?: object[] | undefined; copyActiveItem?: boolean | undefined }): Pane;
177
178 /** Creates a new pane below the receiver. */
179 splitDown(params?: { items?: object[] | undefined; copyActiveItem?: boolean | undefined }): Pane;
180}
181
182export interface PaneListItemShiftedEvent {
183 /** The pane item that was added or removed. */
184 item: object;
185
186 /** A number indicating where the item is located. */
187 index: number;
188}
189
190export interface PaneItemMovedEvent {
191 /** The removed pane item. */
192 item: object;
193
194 /** A number indicating where the item was located. */
195 oldIndex: number;
196
197 /** A number indicating where the item is now located. */
198 newIndex: number;
199}
200
201export interface PaneItemObservedEvent {
202 item: object;
203 pane: Pane;
204 index: number;
205}
206
207export interface PaneItemOpenedEvent extends PaneItemObservedEvent {
208 uri: string;
209}
210
\No newline at end of file