1 | import { Disposable, Pane, PaneItemObservedEvent, TextEditor, TextEditorObservedEvent } from '../index';
|
2 |
|
3 | // https://github.com/atom/atom/blob/master/src/workspace-center.js
|
4 | /** The central container for the editor window capable of holding items. */
|
5 | export interface WorkspaceCenter {
|
6 | // Event Subscription
|
7 | /**
|
8 | * Invoke the given callback with all current and future text editors in the
|
9 | * workspace center.
|
10 | */
|
11 | observeTextEditors(callback: (editor: TextEditor) => void): Disposable;
|
12 |
|
13 | /**
|
14 | * Invoke the given callback with all current and future panes items in the
|
15 | * workspace center.
|
16 | */
|
17 | observePaneItems(callback: (item: object) => void): Disposable;
|
18 |
|
19 | /** Invoke the given callback when the active pane item changes. */
|
20 | onDidChangeActivePaneItem(callback: (item: object) => void): Disposable;
|
21 |
|
22 | /** Invoke the given callback when the active pane item stops changing. */
|
23 | onDidStopChangingActivePaneItem(callback: (item: object) => void): Disposable;
|
24 |
|
25 | /**
|
26 | * Invoke the given callback with the current active pane item and with all future
|
27 | * active pane items in the workspace center.
|
28 | */
|
29 | observeActivePaneItem(callback: (item: object) => void): Disposable;
|
30 |
|
31 | /** Invoke the given callback when a pane is added to the workspace center. */
|
32 | onDidAddPane(callback: (event: { pane: Pane }) => void): Disposable;
|
33 |
|
34 | /** Invoke the given callback before a pane is destroyed in the workspace center. */
|
35 | onWillDestroyPane(callback: (event: { pane: Pane }) => void): Disposable;
|
36 |
|
37 | /** Invoke the given callback when a pane is destroyed in the workspace center. */
|
38 | onDidDestroyPane(callback: (event: { pane: Pane }) => void): Disposable;
|
39 |
|
40 | /** Invoke the given callback with all current and future panes in the workspace center. */
|
41 | observePanes(callback: (pane: Pane) => void): Disposable;
|
42 |
|
43 | /** Invoke the given callback when the active pane changes. */
|
44 | onDidChangeActivePane(callback: (pane: Pane) => void): Disposable;
|
45 |
|
46 | /**
|
47 | * Invoke the given callback with the current active pane and when the active pane
|
48 | * changes.
|
49 | */
|
50 | observeActivePane(callback: (pane: Pane) => void): Disposable;
|
51 |
|
52 | /** Invoke the given callback when a pane item is added to the workspace center. */
|
53 | onDidAddPaneItem(callback: (event: PaneItemObservedEvent) => void): Disposable;
|
54 |
|
55 | /**
|
56 | * Invoke the given callback when a pane item is about to be destroyed, before the user
|
57 | * is prompted to save it.
|
58 | * @param callback The function to be called before pane items are destroyed.
|
59 | * If this function returns a Promise, then the item will not be destroyed
|
60 | * until the promise resolves.
|
61 | */
|
62 | onWillDestroyPaneItem(callback: (event: PaneItemObservedEvent) => void | Promise<void>): Disposable;
|
63 |
|
64 | /** Invoke the given callback when a pane item is destroyed. */
|
65 | onDidDestroyPaneItem(callback: (event: PaneItemObservedEvent) => void): Disposable;
|
66 |
|
67 | /** Invoke the given callback when a text editor is added to the workspace center. */
|
68 | onDidAddTextEditor(callback: (event: TextEditorObservedEvent) => void): Disposable;
|
69 |
|
70 | // Pane Items
|
71 | /** Get all pane items in the workspace center. */
|
72 | getPaneItems(): object[];
|
73 |
|
74 | /** Get the active Pane's active item. */
|
75 | getActivePaneItem(): object | undefined;
|
76 |
|
77 | /** Get all text editors in the workspace center. */
|
78 | getTextEditors(): TextEditor[];
|
79 |
|
80 | /** Get the active item if it is an TextEditor. */
|
81 | getActiveTextEditor(): TextEditor | undefined;
|
82 |
|
83 | /** Save all pane items. */
|
84 | saveAll(): void;
|
85 |
|
86 | // Panes
|
87 | /** Get all panes in the workspace center. */
|
88 | getPanes(): Pane[];
|
89 |
|
90 | /** Get the active Pane. */
|
91 | getActivePane(): Pane;
|
92 |
|
93 | /** Make the next pane active. */
|
94 | activateNextPane(): void;
|
95 |
|
96 | /** Make the previous pane active. */
|
97 | activatePreviousPane(): void;
|
98 |
|
99 | /** Retrieve the Pane associated with the given URI. */
|
100 | paneForURI(uri: string): Pane | undefined;
|
101 |
|
102 | /** Retrieve the Pane associated with the given item. */
|
103 | paneForItem(item: object): Pane | undefined;
|
104 |
|
105 | /** Destroy (close) the active pane. */
|
106 | destroyActivePane(): void;
|
107 | }
|