forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
7166 lines (5681 loc) · 247 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for non-npm package Atom 1.40
// Project: https://github.com/atom/atom
// Definitions by: GlenCFL <https://github.com/GlenCFL>
// smhxx <https://github.com/smhxx>
// lierdakil <https://github.com/lierdakil>
// aminya <https://github.com/aminya>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// NOTE: only those classes exported within this file should be retain that status below.
// https://github.com/atom/atom/blob/v1.40.0/exports/atom.js
/// <reference types="node" />
import { ReadStream, WriteStream } from "fs";
import { ChildProcess } from "child_process";
declare global {
const atom: AtomEnvironment;
interface HTMLElementTagNameMap {
"atom-text-editor": TextEditorElement;
}
}
/**
* Invoke a callback with each filesystem event that occurs beneath a specified path.
* If you only need to watch events within the project's root paths, use
* Project::onDidChangeFiles instead.
*/
export function watchPath(rootPath: string, options: {}, eventCallback: (events:
FilesystemChangeEvent) => void): Promise<PathWatcher>;
// Essential Classes ==========================================================
/**
* Atom global for dealing with packages, themes, menus, and the window.
* An instance of this class is always available as the atom global.
*/
export interface AtomEnvironment {
// Properties
/** A CommandRegistry instance. */
readonly commands: CommandRegistry;
/** A Config instance. */
readonly config: Config;
/** A Clipboard instance. */
readonly clipboard: Clipboard;
/** A ContextMenuManager instance. */
readonly contextMenu: ContextMenuManager;
/** A MenuManager instance. */
readonly menu: MenuManager;
/** A KeymapManager instance. */
readonly keymaps: KeymapManager;
/** A TooltipManager instance. */
readonly tooltips: TooltipManager;
/** A NotificationManager instance. */
readonly notifications: NotificationManager;
/** A Project instance. */
readonly project: Project;
/** A GrammarRegistry instance. */
readonly grammars: GrammarRegistry;
/** A HistoryManager instance. */
readonly history: HistoryManager;
/** A PackageManager instance. */
readonly packages: PackageManager;
/** A ThemeManager instance. */
readonly themes: ThemeManager;
/** A StyleManager instance. */
readonly styles: StyleManager;
/** A DeserializerManager instance. */
readonly deserializers: DeserializerManager;
/** A ViewRegistry instance. */
readonly views: ViewRegistry;
/** A Workspace instance. */
readonly workspace: Workspace;
/** A TextEditorRegistry instance. */
readonly textEditors: TextEditorRegistry;
// Event Subscription
/** Invoke the given callback whenever ::beep is called. */
onDidBeep(callback: () => void): Disposable;
/**
* Invoke the given callback when there is an unhandled error, but before
* the devtools pop open.
*/
onWillThrowError(callback: (event: PreventableExceptionThrownEvent) => void): Disposable;
/** Invoke the given callback whenever there is an unhandled error. */
onDidThrowError(callback: (event: ExceptionThrownEvent) => void): Disposable;
/**
* Invoke the given callback as soon as the shell environment is loaded (or
* immediately if it was already loaded).
*/
whenShellEnvironmentLoaded(callback: () => void): Disposable;
// Atom Details
/** Returns a boolean that is true if the current window is in development mode. */
inDevMode(): boolean;
/** Returns a boolean that is true if the current window is in safe mode. */
inSafeMode(): boolean;
/** Returns a boolean that is true if the current window is running specs. */
inSpecMode(): boolean;
/** Get the full name of this Atom release (e.g. "Atom", "Atom Beta") */
getAppName(): string;
/** Get the version of the Atom application. */
getVersion(): string;
/**
* Gets the release channel of the Atom application.
* Returns the release channel, which can be 'dev', 'nightly', 'beta', or 'stable'.
*/
getReleaseChannel(): "dev"|"nightly"|"beta"|"stable";
/** Returns a boolean that is true if the current version is an official release. */
isReleasedVersion(): boolean;
/** Get the time taken to completely load the current window. */
getWindowLoadTime(): number;
/** Get the all the markers with the information about startup time. */
getStartupMarkers(): TimingMarker[];
/** Get the load settings for the current window. */
getLoadSettings(): WindowLoadSettings;
// Managing the Atom Window
/** Open a new Atom window using the given options. */
open(params?: {
pathsToOpen: ReadonlyArray<string>,
newWindow?: boolean,
devMode?: boolean,
safeMode?: boolean,
}): void;
/** Close the current window. */
close(): void;
/** Get the size of current window. */
getSize(): { width: number, height: number };
/** Set the size of current window. */
setSize(width: number, height: number): void;
/** Get the position of current window. */
getPosition(): { x: number, y: number };
/** Set the position of current window. */
setPosition(x: number, y: number): void;
/** Prompt the user to select one or more folders. */
pickFolder(callback: (paths: string[]|null) => void): void;
/** Get the current window. */
getCurrentWindow(): object;
/** Move current window to the center of the screen. */
center(): void;
/** Focus the current window. */
focus(): void;
/** Show the current window. */
show(): void;
/** Hide the current window. */
hide(): void;
/** Reload the current window. */
reload(): void;
/** Relaunch the entire application. */
restartApplication(): void;
/** Returns a boolean that is true if the current window is maximized. */
isMaximized(): boolean;
/** Returns a boolean that is true if the current window is in full screen mode. */
isFullScreen(): boolean;
/** Set the full screen state of the current window. */
setFullScreen(fullScreen: boolean): void;
/** Toggle the full screen state of the current window. */
toggleFullScreen(): void;
/**
* Restores the full screen and maximized state after the window has resized to prevent resize
* glitches.
*/
displayWindow(): Promise<undefined>;
/** Get the dimensions of this window. */
getWindowDimensions(): { x: number, y: number, width: number, height: number };
/** Set the dimensions of the window. */
setWindowDimensions(dimensions: {
x?: number,
y?: number,
width?: number,
height?: number
}): Promise<object>;
// Messaging the User
/** Visually and audibly trigger a beep. */
beep(): void;
/**
* A flexible way to open a dialog akin to an alert dialog. If a callback
* is provided, then the confirmation will work asynchronously, which is
* recommended.
*
* If the dialog is closed (via `Esc` key or `X` in the top corner) without
* selecting a button the first button will be clicked unless a "Cancel" or "No"
* button is provided.
*
* Returns the chosen button index number if the buttons option was an array.
* @param response The index of the button that was clicked.
* @param checkboxChecked The checked state of the checkbox if `checkboxLabel` was set.
* Otherwise false.
*/
confirm(options: ConfirmationOptions, callback: (response: number,
checkboxChecked: boolean) => void): void;
/**
* A flexible way to open a dialog akin to an alert dialog. If a callback
* is provided, then the confirmation will work asynchronously, which is
* recommended.
*
* If the dialog is closed (via `Esc` key or `X` in the top corner) without
* selecting a button the first button will be clicked unless a "Cancel" or "No"
* button is provided.
*
* Returns the chosen button index number if the buttons option was an array.
*/
confirm(options: {
message: string,
detailedMessage?: string,
buttons?: ReadonlyArray<string>,
}): void;
/**
* A flexible way to open a dialog akin to an alert dialog. If a callback
* is provided, then the confirmation will work asynchronously, which is
* recommended.
*
* If the dialog is closed (via `Esc` key or `X` in the top corner) without
* selecting a button the first button will be clicked unless a "Cancel" or "No"
* button is provided.
*
* Returns the chosen button index number if the buttons option was an array.
*/
confirm(options: {
message: string,
detailedMessage?: string,
buttons?: {
[key: string]: () => void
},
}): number;
// Managing the Dev Tools
/** Open the dev tools for the current window. */
openDevTools(): Promise<null>;
/** Toggle the visibility of the dev tools for the current window. */
toggleDevTools(): Promise<null>;
/** Execute code in dev tools. */
executeJavaScriptInDevTools(code: string): void;
/** Undocumented: get Atom config directory path */
getConfigDirPath(): string;
}
/**
* A simple color class returned from Config::get when the value at the key path is
* of type 'color'.
*/
export interface Color {
/** Returns a string in the form '#abcdef'. */
toHexString(): string;
/** Returns a string in the form 'rgba(25, 50, 75, .9)'. */
toRGBAString(): string;
}
export interface CommandRegistryTargetMap extends HTMLElementTagNameMap {
[key: string]: EventTarget;
}
export type CommandRegistryListener<TargetType extends EventTarget> = {
didDispatch(event: CommandEvent<TargetType>): void | Promise<void>,
displayName?: string,
description?: string,
hiddenInCommandPalette?: boolean,
} | ((event: CommandEvent<TargetType>) => void | Promise<void>);
/**
* Associates listener functions with commands in a context-sensitive way
* using CSS selectors.
*/
export interface CommandRegistry {
/** Register a single command. */
add<T extends keyof CommandRegistryTargetMap>(
target: T, commandName: string,
listener: CommandRegistryListener<CommandRegistryTargetMap[T]>
): Disposable;
/** Register a single command. */
add<T extends Node>(
target: T, commandName: string,
listener: CommandRegistryListener<T>
): Disposable;
/** Register multiple commands. */
add<T extends keyof CommandRegistryTargetMap>(target: T, commands: {
[key: string]: CommandRegistryListener<CommandRegistryTargetMap[T]>
}): CompositeDisposable;
/** Register multiple commands. */
add<T extends Node>(target: T, commands: {
[key: string]: CommandRegistryListener<T>
}): CompositeDisposable;
/** Find all registered commands matching a query. */
findCommands(params: { target: string|Node }): Array<{
name: string,
displayName: string,
description?: string,
tags?: string[],
}>;
/**
* Simulate the dispatch of a command on a DOM node.
* @return Either a Promise that resolves after all handlers complete or null if
* no handlers were matched.
*/
dispatch(target: Node, commandName: string): Promise<void> | null;
/** Invoke the given callback before dispatching a command event. */
onWillDispatch(callback: (event: CommandEvent) => void): Disposable;
/** Invoke the given callback after dispatching a command event. */
onDidDispatch(callback: (event: CommandEvent) => void): Disposable;
}
/**
* An object that aggregates multiple Disposable instances together into a
* single disposable, so they can all be disposed as a group.
*/
export class CompositeDisposable implements DisposableLike {
/** Construct an instance, optionally with one or more disposables. */
constructor(...disposables: DisposableLike[]);
/**
* Dispose all disposables added to this composite disposable.
* If this object has already been disposed, this method has no effect.
*/
dispose(): void;
// Managing Disposables
/**
* Add disposables to be disposed when the composite is disposed.
* If this object has already been disposed, this method has no effect.
*/
add(...disposables: DisposableLike[]): void;
/** Remove a previously added disposable. */
remove(disposable: DisposableLike): void;
/** Alias to CompositeDisposable::remove. */
delete(disposable: DisposableLike): void;
/**
* Clear all disposables. They will not be disposed by the next call to
* dispose.
*/
clear(): void;
}
/** Used to access all of Atom's configuration details. */
export interface Config {
// Config Subscription
/**
* Add a listener for changes to a given key path. This is different than ::onDidChange in
* that it will immediately call your callback with the current value of the config entry.
*/
observe<T extends keyof ConfigValues>(keyPath: T, callback:
(value: ConfigValues[T]) => void): Disposable;
/**
* Add a listener for changes to a given key path. This is different than ::onDidChange in
* that it will immediately call your callback with the current value of the config entry.
*/
observe<T extends keyof ConfigValues>(keyPath: T, options:
{ scope: string[]|ScopeDescriptor }, callback: (value: ConfigValues[T]) => void):
Disposable;
/**
* Add a listener for changes to a given key path. If keyPath is not specified, your
* callback will be called on changes to any key.
*/
// tslint:disable-next-line:no-any
onDidChange<T = any>(callback: (values: { newValue: T, oldValue: T }) => void):
Disposable;
/**
* Add a listener for changes to a given key path. If keyPath is not specified, your
* callback will be called on changes to any key.
*/
onDidChange<T extends keyof ConfigValues>(keyPath: T, callback: (values: {
newValue: ConfigValues[T],
oldValue?: ConfigValues[T],
}) => void): Disposable;
/**
* Add a listener for changes to a given key path. If keyPath is not specified, your
* callback will be called on changes to any key.
*/
onDidChange<T extends keyof ConfigValues>(keyPath: T, options:
{ scope: string[]|ScopeDescriptor }, callback:
(values: { newValue: ConfigValues[T], oldValue?: ConfigValues[T] }) => void):
Disposable;
// Managing Settings
/** Retrieves the setting for the given key. */
get<T extends keyof ConfigValues>(keyPath: T, options?: { sources?: string[],
excludeSources?: string[], scope?: string[]|ScopeDescriptor }):
ConfigValues[T];
/**
* Sets the value for a configuration setting.
* This value is stored in Atom's internal configuration file.
*/
set<T extends keyof ConfigValues>(keyPath: T, value: ConfigValues[T], options?:
{ scopeSelector?: string, source?: string }): void;
/** Restore the setting at keyPath to its default value. */
unset(keyPath: string, options?: { scopeSelector?: string, source?: string }): void;
/**
* Get all of the values for the given key-path, along with their associated
* scope selector.
*/
getAll<T extends keyof ConfigValues>(keyPath: T, options?: { sources?: string[],
excludeSources?: string[], scope?: ScopeDescriptor }):
Array<{ scopeDescriptor: ScopeDescriptor, value: ConfigValues[T] }>;
/**
* Get an Array of all of the source Strings with which settings have been added
* via ::set.
*/
getSources(): string[];
/**
* Retrieve the schema for a specific key path. The schema will tell you what type
* the keyPath expects, and other metadata about the config option.
*/
getSchema(keyPath: string): object|null;
/** Get the string path to the config file being used. */
getUserConfigPath(): string;
/**
* Suppress calls to handler functions registered with ::onDidChange and ::observe
* for the duration of callback. After callback executes, handlers will be called
* once if the value for their key-path has changed.
*/
transact(callback: () => void): void;
}
/**
* Represents a decoration that follows a DisplayMarker. A decoration is basically
* a visual representation of a marker. It allows you to add CSS classes to line
* numbers in the gutter, lines, and add selection-line regions around marked ranges
* of text.
*/
export interface Decoration {
/** The identifier for this Decoration. */
readonly id: number;
// Construction and Destruction
/**
* Destroy this marker decoration.
* You can also destroy the marker if you own it, which will destroy this decoration.
*/
destroy(): void;
// Event Subscription
/** When the Decoration is updated via Decoration::setProperties. */
onDidChangeProperties(callback: (event: DecorationPropsChangedEvent) => void): Disposable;
/** Invoke the given callback when the Decoration is destroyed. */
onDidDestroy(callback: () => void): Disposable;
// Decoration Details
/** An id unique across all Decoration objects. */
getId(): number;
/** Returns the marker associated with this Decoration. */
getMarker(): DisplayMarker;
/**
* Check if this decoration is of the given type.
* @param type A decoration type, such as `line-number` or `line`. This may also
* be an array of decoration types, with isType returning true if the decoration's
* type matches any in the array.
*/
isType(type: string|string[]): boolean;
// Properties
/** Returns the Decoration's properties. */
getProperties(): DecorationOptions;
/**
* Update the marker with new Properties. Allows you to change the decoration's
* class.
*/
setProperties(newProperties: DecorationOptions): void;
}
/**
* Represents a buffer annotation that remains logically stationary even as the
* buffer changes. This is used to represent cursors, folds, snippet targets,
* misspelled words, and anything else that needs to track a logical location
* in the buffer over time.
*/
export interface DisplayMarker {
// Construction and Destruction
/**
* Destroys the marker, causing it to emit the 'destroyed' event. Once destroyed,
* a marker cannot be restored by undo/redo operations.
*/
destroy(): void;
/** Creates and returns a new DisplayMarker with the same properties as this marker. */
copy(options?: CopyMarkerOptions): DisplayMarker;
// Event Subscription
/** Invoke the given callback when the state of the marker changes. */
onDidChange(callback: (event: DisplayMarkerChangedEvent) => void): Disposable;
/** Invoke the given callback when the marker is destroyed. */
onDidDestroy(callback: () => void): Disposable;
// TextEditorMarker Details
/**
* Returns a boolean indicating whether the marker is valid. Markers can be
* invalidated when a region surrounding them in the buffer is changed.
*/
isValid(): boolean;
/**
* Returns a boolean indicating whether the marker has been destroyed. A marker
* can be invalid without being destroyed, in which case undoing the invalidating
* operation would restore the marker.
*/
isDestroyed(): boolean;
/** Returns a boolean indicating whether the head precedes the tail. */
isReversed(): boolean;
/**
* Returns a boolean indicating whether changes that occur exactly at the marker's
* head or tail cause it to move.
*/
isExclusive(): boolean;
/**
* Get the invalidation strategy for this marker.
* Valid values include: never, surround, overlap, inside, and touch.
*/
getInvalidationStrategy(): string;
/** Returns an Object containing any custom properties associated with the marker. */
getProperties(): object;
/** Merges an Object containing new properties into the marker's existing properties. */
setProperties(properties: object): void;
/** Returns whether this marker matches the given parameters. */
matchesProperties(attributes: FindDisplayMarkerOptions): boolean;
// Comparing to other markers
/** Compares this marker to another based on their ranges. */
compare(other: DisplayMarker): number;
/**
* Returns a boolean indicating whether this marker is equivalent to another
* marker, meaning they have the same range and options.
*/
isEqual(other: DisplayMarker): boolean;
// Managing the marker's range
/** Gets the buffer range of this marker. */
getBufferRange(): Range;
/** Gets the screen range of this marker. */
getScreenRange(): Range;
/** Modifies the buffer range of this marker. */
setBufferRange(bufferRange: RangeCompatible, properties?: { reversed: boolean }):
void;
/** Modifies the screen range of this marker. */
setScreenRange(screenRange: RangeCompatible, options?: { reversed?: boolean,
clipDirection?: "backward"|"forward"|"closest" }): void;
/**
* Retrieves the screen position of the marker's start. This will always be
* less than or equal to the result of DisplayMarker::getEndScreenPosition.
*/
getStartScreenPosition(options?: { clipDirection: "backward"|"forward"|"closest" }):
Point;
/**
* Retrieves the screen position of the marker's end. This will always be
* greater than or equal to the result of DisplayMarker::getStartScreenPosition.
*/
getEndScreenPosition(options?: { clipDirection: "backward"|"forward"|"closest" }):
Point;
/** Retrieves the buffer position of the marker's head. */
getHeadBufferPosition(): Point;
/** Sets the buffer position of the marker's head. */
setHeadBufferPosition(bufferPosition: PointCompatible): void;
/** Retrieves the screen position of the marker's head. */
getHeadScreenPosition(options?: { clipDirection: "backward"|"forward"|"closest" }):
Point;
/** Sets the screen position of the marker's head. */
setHeadScreenPosition(screenPosition: PointCompatible,
options?: { clipDirection: "backward"|"forward"|"closest" }): void;
/** Retrieves the buffer position of the marker's tail. */
getTailBufferPosition(): Point;
/** Sets the buffer position of the marker's tail. */
setTailBufferPosition(bufferPosition: PointCompatible): void;
/** Retrieves the screen position of the marker's tail. */
getTailScreenPosition(options?: { clipDirection: "backward"|"forward"|"closest" }):
Point;
/** Sets the screen position of the marker's tail. */
setTailScreenPosition(screenPosition: PointCompatible,
options?: { clipDirection: "backward"|"forward"|"closest" }): void;
/**
* Retrieves the buffer position of the marker's start. This will always be less
* than or equal to the result of DisplayMarker::getEndBufferPosition.
*/
getStartBufferPosition(): Point;
/**
* Retrieves the buffer position of the marker's end. This will always be greater
* than or equal to the result of DisplayMarker::getStartBufferPosition.
*/
getEndBufferPosition(): Point;
/** Returns a boolean indicating whether the marker has a tail. */
hasTail(): boolean;
/**
* Plants the marker's tail at the current head position. After calling the
* marker's tail position will be its head position at the time of the call,
* regardless of where the marker's head is moved.
*/
plantTail(): void;
/**
* Removes the marker's tail. After calling the marker's head position will be
* reported as its current tail position until the tail is planted again.
*/
clearTail(): void;
}
/**
* Experimental: A container for a related set of markers at the DisplayLayer level.
* Wraps an underlying MarkerLayer on the TextBuffer.
*
* This API is experimental and subject to change on any release.
*/
export interface DisplayMarkerLayer {
/** The identifier for the underlying MarkerLayer. */
readonly id: string;
// Lifecycle
/** Destroy this layer. */
destroy(): void;
/** Destroy all markers in this layer. */
clear(): void;
/** Determine whether this layer has been destroyed. */
isDestroyed(): boolean;
// Event Subscription
/** Subscribe to be notified synchronously when this layer is destroyed. */
onDidDestroy(callback: () => void): Disposable;
/**
* Subscribe to be notified asynchronously whenever markers are created, updated,
* or destroyed on this layer. Prefer this method for optimal performance when
* interacting with layers that could contain large numbers of markers.
*/
onDidUpdate(callback: () => void): Disposable;
/**
* Subscribe to be notified synchronously whenever markers are created on this
* layer. Avoid this method for optimal performance when interacting with layers
* that could contain large numbers of markers.
*/
onDidCreateMarker(callback: (marker: DisplayMarker|Marker) => void): Disposable;
// Marker creation
/** Create a marker with the given screen range. */
markScreenRange(range: RangeCompatible, options?: { reversed?: boolean,
invalidate?: "never"|"surround"|"overlap"|"inside"|"touch", exclusive?:
boolean, clipDirection?: "backward"|"forward"|"closest" }): DisplayMarker;
/**
* Create a marker on this layer with its head at the given screen position
* and no tail.
*/
markScreenPosition(screenPosition: PointCompatible, options?: { invalidate?:
"never"|"surround"|"overlap"|"inside"|"touch", exclusive?: boolean,
clipDirection?: "backward"|"forward"|"closest" }): DisplayMarker;
/** Create a marker with the given buffer range. */
markBufferRange(range: RangeCompatible, options?: {
reversed?: boolean, invalidate?: "never"|"surround"|"overlap"|"inside"|"touch",
exclusive?: boolean }): DisplayMarker;
/**
* Create a marker on this layer with its head at the given buffer position
* and no tail.
*/
markBufferPosition(bufferPosition: PointCompatible, options?: { invalidate?:
"never"|"surround"|"overlap"|"inside"|"touch", exclusive?: boolean }):
DisplayMarker;
// Querying
/** Get an existing marker by its id. */
getMarker(id: number): DisplayMarker;
/** Get all markers in the layer. */
getMarkers(): DisplayMarker[];
/** Get the number of markers in the marker layer. */
getMarkerCount(): number;
/**
* Find markers in the layer conforming to the given parameters.
*
* This method finds markers based on the given properties. Markers can be associated
* with custom properties that will be compared with basic equality. In addition,
* there are several special properties that will be compared with the range of the
* markers rather than their properties.
*/
findMarkers(properties: FindDisplayMarkerOptions): DisplayMarker[];
}
/** A handle to a resource that can be disposed. */
export class Disposable implements DisposableLike {
/** Ensure that Object correctly implements the Disposable contract. */
static isDisposable(object: object): boolean;
/** Construct a Disposable. */
constructor(disposableAction?: () => void);
/** A callback which will be called within dispose(). */
disposalAction?(): void;
/**
* Perform the disposal action, indicating that the resource associated
* with this disposable is no longer needed.
*/
dispose(): void;
}
/**
* Utility class to be used when implementing event-based APIs that allows
* for handlers registered via ::on to be invoked with calls to ::emit.
*/
// tslint:disable-next-line:no-any
export class Emitter<OptionalEmissions = { [key: string]: any }, RequiredEmissions = {}>
implements DisposableLike {
/** Construct an emitter. */
constructor();
/** Clear out any existing subscribers. */
clear(): void;
/** Unsubscribe all handlers. */
dispose(): boolean;
// Event Subscription
/** Registers a handler to be invoked whenever the given event is emitted. */
on<T extends keyof OptionalEmissions>(eventName: T, handler: (value?:
OptionalEmissions[T]) => void): Disposable;
/** Registers a handler to be invoked whenever the given event is emitted. */
on<T extends keyof RequiredEmissions>(eventName: T, handler: (value:
RequiredEmissions[T]) => void): Disposable;
/**
* Register the given handler function to be invoked the next time an event
* with the given name is emitted via ::emit.
*/
once<T extends keyof OptionalEmissions>(eventName: T, handler: (value?:
OptionalEmissions[T]) => void): Disposable;
/**
* Register the given handler function to be invoked the next time an event
* with the given name is emitted via ::emit.
*/
once<T extends keyof RequiredEmissions>(eventName: T, handler: (value:
RequiredEmissions[T]) => void): Disposable;
/**
* Register the given handler function to be invoked before all other
* handlers existing at the time of subscription whenever events by the
* given name are emitted via ::emit.
*/
preempt<T extends keyof OptionalEmissions>(eventName: T, handler: (value?:
OptionalEmissions[T]) => void): Disposable;
/**
* Register the given handler function to be invoked before all other
* handlers existing at the time of subscription whenever events by the
* given name are emitted via ::emit.
*/
preempt<T extends keyof RequiredEmissions>(eventName: T, handler: (value:
RequiredEmissions[T]) => void): Disposable;
// Event Emission
/** Invoke the handlers registered via ::on for the given event name. */
emit<T extends keyof OptionalEmissions>(eventName: T, value?:
OptionalEmissions[T]): void;
/** Invoke the handlers registered via ::on for the given event name. */
emit<T extends keyof RequiredEmissions>(eventName: T, value:
RequiredEmissions[T]): void;
}
/**
* Represents a decoration that applies to every marker on a given layer. Created via
* TextEditor::decorateMarkerLayer.
*/
export interface LayerDecoration {
/** Destroys the decoration. */
destroy(): void;
/** Determine whether this decoration is destroyed. */
isDestroyed(): boolean;
/** Get this decoration's properties. */
getProperties(): DecorationLayerOptions;
/** Set this decoration's properties. */
setProperties(newProperties: DecorationLayerOptions): void;
/** Override the decoration properties for a specific marker. */
setPropertiesForMarker(marker: DisplayMarker|Marker, properties: DecorationLayerOptions):
void;
}
/**
* Represents a buffer annotation that remains logically stationary even as
* the buffer changes.
*/
export interface Marker {
/** The identifier for this Marker. */
readonly id: number;
// Lifecycle
/**
* Creates and returns a new Marker with the same properties as this
* marker.
*/
copy(options?: CopyMarkerOptions): Marker;
/** Destroys the marker, causing it to emit the "destroyed" event. */
destroy(): void;
// Event Subscription
/** Invoke the given callback when the marker is destroyed. */
onDidDestroy(callback: () => void): Disposable;
/** Invoke the given callback when the state of the marker changes. */
onDidChange(callback: (event: MarkerChangedEvent) => void): Disposable;
// Marker Details
/** Returns the current range of the marker. The range is immutable. */
getRange(): Range;
/** Returns a point representing the marker's current head position. */
getHeadPosition(): Point;
/** Returns a point representing the marker's current tail position. */
getTailPosition(): Point;
/**
* Returns a point representing the start position of the marker, which
* could be the head or tail position, depending on its orientation.
*/
getStartPosition(): Point;
/**
* Returns a point representing the end position of the marker, which
* could be the head or tail position, depending on its orientation.
*/
getEndPosition(): Point;
/** Returns a boolean indicating whether the head precedes the tail. */
isReversed(): boolean;
/** Returns a boolean indicating whether the marker has a tail. */
hasTail(): boolean;
/** Is the marker valid? */
isValid(): boolean;
/** Is the marker destroyed? */
isDestroyed(): boolean;
/**
* Returns a boolean indicating whether changes that occur exactly at
* the marker's head or tail cause it to move.
*/
isExclusive(): boolean;
/** Get the invalidation strategy for this marker. */
getInvalidationStrategy(): string;
// Mutating Markers
/**
* Sets the range of the marker.
* Returns a boolean indicating whether or not the marker was updated.
*/
setRange(range: RangeCompatible, params?: { reversed?: boolean, exclusive?:
boolean }): boolean;
/**
* Sets the head position of the marker.
* Returns a boolean indicating whether or not the marker was updated.
*/
setHeadPosition(position: PointCompatible): boolean;
/**
* Sets the tail position of the marker.
* Returns a boolean indicating whether or not the marker was updated.
*/
setTailPosition(position: PointCompatible): boolean;
/**
* Removes the marker's tail.
* Returns a boolean indicating whether or not the marker was updated.
*/
clearTail(): boolean;
/**
* Plants the marker's tail at the current head position.
* Returns a boolean indicating whether or not the marker was updated.
*/
plantTail(): boolean;
// Comparison
/**
* Returns a boolean indicating whether this marker is equivalent to
* another marker, meaning they have the same range and options.
*/
isEqual(other: Marker): boolean;
/**
* Compares this marker to another based on their ranges.
* Returns "-1" if this marker precedes the argument.
* Returns "0" if this marker is equivalent to the argument.
* Returns "1" if this marker follows the argument.
*/
compare(other: Marker): number;
}
/** Experimental: A container for a related set of markers. */