UNPKG

8.72 kBTypeScriptView Raw
1// This file holds the types that don't belong to a specific file.
2// Please don't import types from this file directly as its content might change in other versions.
3
4import { AtomEnvironment, DecorationOptions, MarkerLayer, Pane, Point, TextEditor } from "../index";
5
6export interface PixelPosition {
7 left: number;
8 top: number;
9}
10
11/**
12 * This custom subclass of CustomEvent exists to provide the ::abortKeyBinding
13 * method, as well as versions of the ::stopPropagation methods that record the
14 * intent to stop propagation so event bubbling can be properly simulated for
15 * detached elements.
16 */
17export interface CommandEvent<CurrentTarget extends EventTarget = EventTarget> extends CustomEvent {
18 keyBindingAborted: boolean;
19 propagationStopped: boolean;
20
21 abortKeyBinding(): void;
22 stopPropagation(): CustomEvent;
23 stopImmediatePropagation(): CustomEvent;
24 currentTarget: CurrentTarget;
25}
26
27export interface DecorationPropsChangedEvent {
28 /** Object the old parameters the decoration used to have. */
29 oldProperties: DecorationOptions;
30
31 /** Object the new parameters the decoration now has */
32 newProperties: DecorationOptions;
33}
34
35export interface EditorChangedEvent {
36 /** A Point representing where the change started. */
37 start: Point;
38
39 /** A Point representing the replaced extent. */
40 oldExtent: Point;
41
42 /** A Point representing the replacement extent. */
43 newExtent: Point;
44}
45
46export interface FileSavedEvent {
47 /** The path to which the buffer was saved. */
48 path: string;
49}
50
51export interface FilesystemChangeBasic<
52 Action extends "created" | "modified" | "deleted" | "renamed" = "created" | "modified" | "deleted",
53> {
54 /** A string describing the filesystem action that occurred. */
55 action: Action;
56
57 /** The absolute path to the filesystem entry that was acted upon. */
58 path: string;
59}
60
61export interface FilesystemChangeRename extends FilesystemChangeBasic<"renamed"> {
62 /**
63 * For rename events, a string containing the filesystem entry's former
64 * absolute path.
65 */
66 oldPath: string;
67}
68
69export type FilesystemChange = FilesystemChangeBasic | FilesystemChangeRename;
70
71export type FilesystemChangeEvent = FilesystemChange[];
72
73export interface HandleableErrorEvent {
74 /** The error object. */
75 error: Error;
76
77 /**
78 * Call this function to indicate you have handled the error.
79 * The error will not be thrown if this function is called.
80 */
81 handle(): void;
82}
83
84export interface TextEditorObservedEvent {
85 textEditor: TextEditor;
86 pane: Pane;
87 index: number;
88}
89
90export interface BuildEnvironmentOptions {
91 /**
92 * An object responsible for Atom's interaction with the browser process and host OS.
93 * Use buildDefaultApplicationDelegate for a default instance.
94 */
95 applicationDelegate?: object | undefined;
96
97 /** A window global. */
98 window?: Window | undefined;
99
100 /** A document global. */
101 document?: Document | undefined;
102
103 /** A path to the configuration directory (usually ~/.atom). */
104 configDirPath?: string | undefined;
105
106 /**
107 * A boolean indicating whether the Atom environment should save or load state
108 * from the file system. You probably want this to be false.
109 */
110 enablePersistence?: boolean | undefined;
111}
112
113export interface HistoryTransactionOptions {
114 /** When provided, skip taking snapshot for other selections markerLayers except given one. */
115 selectionsMarkerLayer?: MarkerLayer | undefined;
116}
117
118export interface HistoryTraversalOptions {
119 /** Restore snapshot of selections marker layer to given selectionsMarkerLayer. */
120 selectionsMarkerLayer?: MarkerLayer | undefined;
121}
122
123export interface ReadonlyEditOptions {
124 /** Whether the readonly protections on the text editor should be ignored. */
125 bypassReadOnly?: boolean | undefined;
126}
127
128export interface TextEditOptions {
129 /** If true, all line endings will be normalized to match the editor's current mode. */
130 normalizeLineEndings?: boolean | undefined;
131
132 /**
133 * If skip, skips the undo stack for this operation.
134 * @deprecated Call groupLastChanges() on the TextBuffer afterward instead.
135 */
136 undo?: "skip" | undefined;
137}
138
139export interface TextInsertionOptions extends TextEditOptions {
140 /** If true, selects the newly added text. */
141 select?: boolean | undefined;
142
143 /** If true, indents all inserted text appropriately. */
144 autoIndent?: boolean | undefined;
145
146 /** If true, indent newline appropriately. */
147 autoIndentNewline?: boolean | undefined;
148
149 /**
150 * If true, decreases indent level appropriately (for example, when a closing
151 * bracket is inserted).
152 */
153 autoDecreaseIndent?: boolean | undefined;
154
155 /**
156 * By default, when pasting multiple lines, Atom attempts to preserve the relative
157 * indent level between the first line and trailing lines, even if the indent
158 * level of the first line has changed from the copied text. If this option is
159 * true, this behavior is suppressed.
160 */
161 preserveTrailingLineIndentation?: boolean | undefined;
162}
163
164/** An interface which all custom test runners should implement. */
165export type TestRunner = (params: TestRunnerParams) => Promise<number>;
166
167export interface CancellablePromise<T> extends Promise<T> {
168 cancel(): void;
169}
170
171export type FileEncoding =
172 | "iso88596" // Arabic (ISO 8859-6)
173 | "windows1256" // Arabic (Windows 1256)
174 | "iso88594" // Baltic (ISO 8859-4)
175 | "windows1257" // Baltic (Windows 1257)
176 | "iso885914" // Celtic (ISO 8859-14)
177 | "iso88592" // Central European (ISO 8859-2)
178 | "windows1250" // Central European (Windows 1250)
179 | "gb18030" // Chinese (GB18030)
180 | "gbk" // Chinese (GBK)
181 | "cp950" // Traditional Chinese (Big5)
182 | "big5hkscs" // Traditional Chinese (Big5-HKSCS)
183 | "cp866" // Cyrillic (CP 866)
184 | "iso88595" // Cyrillic (ISO 8859-5)
185 | "koi8r" // Cyrillic (KOI8-R)
186 | "koi8u" // Cyrillic (KOI8-U)
187 | "windows1251" // Cyrillic (Windows 1251)
188 | "cp437" // DOS (CP 437)
189 | "cp850" // DOS (CP 850)
190 | "iso885913" // Estonian (ISO 8859-13)
191 | "iso88597" // Greek (ISO 8859-7)
192 | "windows1253" // Greek (Windows 1253)
193 | "iso88598" // Hebrew (ISO 8859-8)
194 | "windows1255" // Hebrew (Windows 1255)
195 | "cp932" // Japanese (CP 932)
196 | "eucjp" // Japanese (EUC-JP)
197 | "shiftjis" // Japanese (Shift JIS)
198 | "euckr" // Korean (EUC-KR)
199 | "iso885910" // Nordic (ISO 8859-10)
200 | "iso885916" // Romanian (ISO 8859-16)
201 | "iso88599" // Turkish (ISO 8859-9)
202 | "windows1254" // Turkish (Windows 1254)
203 | "utf8" // Unicode (UTF-8)
204 | "utf16le" // Unicode (UTF-16 LE)
205 | "utf16be" // Unicode (UTF-16 BE)
206 | "windows1258" // Vietnamese (Windows 1258)
207 | "iso88591" // Western (ISO 8859-1)
208 | "iso88593" // Western (ISO 8859-3)
209 | "iso885915" // Western (ISO 8859-15)
210 | "macroman" // Western (Mac Roman)
211 | "windows1252"; // Western (Windows 1252)
212
213export interface Invisibles {
214 /**
215 * Character used to render newline characters (\n) when the `Show Invisibles`
216 * setting is enabled.
217 */
218 eol?: boolean | string | undefined;
219
220 /**
221 * Character used to render leading and trailing space characters when the
222 * `Show Invisibles` setting is enabled.
223 */
224 space?: boolean | string | undefined;
225
226 /**
227 * Character used to render hard tab characters (\t) when the `Show Invisibles`
228 * setting is enabled.
229 */
230 tab?: boolean | string | undefined;
231
232 /**
233 * Character used to render carriage return characters (for Microsoft-style line
234 * endings) when the `Show Invisibles` setting is enabled.
235 */
236 cr?: boolean | string | undefined;
237}
238
239export interface TestRunnerParams {
240 /** An array of paths to tests to run. Could be paths to files or directories. */
241 testPaths: string[];
242
243 /**
244 * A function that can be called to construct an instance of the atom global.
245 * No atom global will be explicitly assigned, but you can assign one in your
246 * runner if desired.
247 */
248 buildAtomEnvironment(options: BuildEnvironmentOptions): AtomEnvironment;
249
250 /**
251 * A function that builds a default instance of the application delegate, suitable
252 * to be passed as the applicationDelegate parameter to buildAtomEnvironment.
253 */
254 buildDefaultApplicationDelegate(): object;
255
256 /** An optional path to a log file to which test output should be logged. */
257 logFile: string;
258
259 /**
260 * A boolean indicating whether or not the tests are being run from the command
261 * line via atom --test.
262 */
263 headless: boolean;
264}