UNPKG

1.53 kBTypeScriptView Raw
1import { Disposable, TextEditor } from '../index';
2
3/** Experimental: This global registry tracks registered TextEditors. */
4export interface TextEditorRegistry {
5 // Managing Text Editors
6 /** Remove all editors from the registry. */
7 clear(): void;
8
9 /** Register a TextEditor. */
10 add(editor: TextEditor): Disposable;
11
12 /** Remove the given TextEditor from the registry. */
13 remove(editor: TextEditor): boolean;
14
15 /** Keep a TextEditor's configuration in sync with Atom's settings. */
16 maintainConfig(editor: TextEditor): Disposable;
17
18 /**
19 * Set a TextEditor's grammar based on its path and content, and continue
20 * to update its grammar as gramamrs are added or updated, or the editor's
21 * file path changes.
22 */
23 maintainGrammar(editor: TextEditor): Disposable;
24
25 /**
26 * Force a TextEditor to use a different grammar than the one that would
27 * otherwise be selected for it.
28 */
29 setGrammarOverride(editor: TextEditor, scopeName: string): void;
30
31 /**
32 * Retrieve the grammar scope name that has been set as a grammar override
33 * for the given TextEditor.
34 */
35 getGrammarOverride(editor: TextEditor): string | null;
36
37 /** Remove any grammar override that has been set for the given TextEditor. */
38 clearGrammarOverride(editor: TextEditor): void;
39
40 // Event Subscription
41 /** Invoke the given callback with all the current and future registered TextEditors. */
42 observe(callback: (editor: TextEditor) => void): Disposable;
43}