UNPKG

3.32 kBTypeScriptView Raw
1import { Decoration, DecorationOptions, DisplayMarker, Disposable } from "../index";
2
3/** Represents a gutter within a TextEditor. */
4export interface Gutter {
5 // Gutter Destruction
6 /** Destroys the gutter. */
7 destroy(): void;
8
9 // Event Subscription
10 /** Calls your callback when the gutter's visibility changes. */
11 onDidChangeVisible(callback: (gutter: Gutter) => void): Disposable;
12
13 /** Calls your callback when the gutter is destroyed. */
14 onDidDestroy(callback: () => void): Disposable;
15
16 // Visibility
17 /** Hide the gutter. */
18 hide(): void;
19
20 /** Show the gutter. */
21 show(): void;
22
23 /** Determine whether the gutter is visible. */
24 isVisible(): boolean;
25
26 /**
27 * Add a decoration that tracks a DisplayMarker. When the marker moves, is
28 * invalidated, or is destroyed, the decoration will be updated to reflect
29 * the marker's state.
30 */
31 decorateMarker(marker: DisplayMarker, decorationParams: DecorationOptions): Decoration;
32}
33
34export interface GutterOptions {
35 /** (required) A unique String to identify this gutter. */
36 name: string;
37
38 /**
39 * A Number that determines stacking order between gutters.
40 * Lower priority items are forced closer to the edges of the window. (default: -100)
41 */
42 priority?: number | undefined;
43
44 /**
45 * Boolean specifying whether the gutter is visible initially after being created.
46 * (default: true)
47 */
48 visible?: boolean | undefined;
49
50 /**
51 * String specifying the type of gutter to create.
52 * 'decorated' gutters are useful as a destination for decorations created with
53 * Gutter::decorateMarker.
54 * 'line-number' gutters.
55 */
56 type?: "decorated" | "line-number" | undefined;
57
58 /** String added to the CSS classnames of the gutter's root DOM element. */
59 class?: string | undefined;
60
61 /**
62 * Function called by a 'line-number' gutter to generate the label for each
63 * line number element. Should return a String that will be used to label the
64 * corresponding line.
65 */
66 labelFn?: ((lineData: LineDataExtended) => string) | undefined;
67
68 /**
69 * Function to be called when a mousedown event is received by a line-number
70 * element within this type: 'line-number' Gutter. If unspecified, the default
71 * behavior is to select the clicked buffer row.
72 */
73 onMouseDown?: ((lineData: LineData) => void) | undefined;
74
75 /**
76 * Function to be called when a mousemove event occurs on a line-number
77 * element within within this type: 'line-number' Gutter.
78 */
79 onMouseMove?: ((lineData: LineData) => void) | undefined;
80}
81
82export interface LineData {
83 /** Number indicating the zero-indexed buffer index of a line. */
84 bufferRow: number;
85
86 /** Number indicating the zero-indexed screen index. */
87 screenRow: number;
88}
89
90/** Object containing information about each line to label. */
91export interface LineDataExtended extends LineData {
92 /** Boolean that is true if a fold may be created here. */
93 foldable: boolean;
94
95 /** Boolean if this screen row is the soft-wrapped continuation of the same buffer row. */
96 softWrapped: boolean;
97
98 /** Number the maximum number of digits necessary to represent any known screen row. */
99 maxDigits: number;
100}
101
\No newline at end of file