UNPKG

3.4 kBTypeScriptView Raw
1import { Disposable } from '../../../index';
2import { Marker, PointCompatible, RangeCompatible } from './text-buffer';
3
4/** Experimental: A container for a related set of markers. */
5export interface MarkerLayer {
6 /** The identifier for this MarkerLayer. */
7 readonly id: string;
8
9 // Lifecycle
10 /** Create a copy of this layer with markers in the same state and locations. */
11 copy(): MarkerLayer;
12
13 /** Destroy this layer. */
14 destroy(): boolean;
15
16 /** Remove all markers from this layer. */
17 clear(): void;
18
19 /** Determine whether this layer has been destroyed. */
20 isDestroyed(): boolean;
21
22 // Querying
23 /** Get an existing marker by its id. */
24 getMarker(id: number): Marker | undefined;
25
26 /** Get all existing markers on the marker layer. */
27 getMarkers(): Marker[];
28
29 /** Get the number of markers in the marker layer. */
30 getMarkerCount(): number;
31
32 /** Find markers in the layer conforming to the given parameters. */
33 findMarkers(params: FindMarkerOptions): Marker[];
34
35 /** Get the role of the marker layer e.g. "atom.selection". */
36 getRole(): string | undefined;
37
38 // Marker Creation
39 /** Create a marker with the given range. */
40 markRange(
41 range: RangeCompatible,
42 options?: {
43 reversed?: boolean | undefined;
44 invalidate?: 'never' | 'surround' | 'overlap' | 'inside' | 'touch' | undefined;
45 exclusive?: boolean | undefined;
46 },
47 ): Marker;
48
49 /** Create a marker at with its head at the given position with no tail. */
50 markPosition(
51 position: PointCompatible,
52 options?: {
53 invalidate?: 'never' | 'surround' | 'overlap' | 'inside' | 'touch' | undefined;
54 exclusive?: boolean | undefined;
55 },
56 ): Marker;
57
58 // Event Subscription
59 /**
60 * Subscribe to be notified asynchronously whenever markers are created,
61 * updated, or destroyed on this layer.
62 */
63 onDidUpdate(callback: () => void): Disposable;
64
65 /**
66 * Subscribe to be notified synchronously whenever markers are created on
67 * this layer.
68 */
69 onDidCreateMarker(callback: (marker: Marker) => void): Disposable;
70
71 /** Subscribe to be notified synchronously when this layer is destroyed. */
72 onDidDestroy(callback: () => void): Disposable;
73}
74
75export interface FindMarkerOptions {
76 /** Only include markers that start at the given Point. */
77 startPosition?: PointCompatible | undefined;
78
79 /** Only include markers that end at the given Point. */
80 endPosition?: PointCompatible | undefined;
81
82 /** Only include markers that start inside the given Range. */
83 startsInRange?: RangeCompatible | undefined;
84
85 /** Only include markers that end inside the given Range. */
86 endsInRange?: RangeCompatible | undefined;
87
88 /** Only include markers that contain the given Point, inclusive. */
89 containsPoint?: PointCompatible | undefined;
90
91 /** Only include markers that contain the given Range, inclusive. */
92 containsRange?: RangeCompatible | undefined;
93
94 /** Only include markers that start at the given row number. */
95 startRow?: number | undefined;
96
97 /** Only include markers that end at the given row number. */
98 endRow?: number | undefined;
99
100 /** Only include markers that intersect the given row number. */
101 intersectsRow?: number | undefined;
102}