@pulsar-edit/types 1.128.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/.github/workflows/publish.yml +33 -0
  2. package/LICENSE.md +8 -0
  3. package/README.md +187 -0
  4. package/atom-i18n/config.d.ts +9 -0
  5. package/atom-i18n/index.d.ts +4 -0
  6. package/autocomplete-plus/config.d.ts +140 -0
  7. package/autocomplete-plus/index.d.ts +200 -0
  8. package/dependencies/event-kit/index.d.ts +143 -0
  9. package/dependencies/first-mate/index.d.ts +1 -0
  10. package/dependencies/first-mate/src/first-mate.d.ts +1 -0
  11. package/dependencies/first-mate/src/grammar.d.ts +119 -0
  12. package/dependencies/pathwatcher/index.d.ts +1 -0
  13. package/dependencies/pathwatcher/src/directory.d.ts +98 -0
  14. package/dependencies/pathwatcher/src/file.d.ts +115 -0
  15. package/dependencies/pathwatcher/src/main.d.ts +2 -0
  16. package/dependencies/service-hub/index.d.ts +3 -0
  17. package/dependencies/service-hub/src/consumer.d.ts +8 -0
  18. package/dependencies/service-hub/src/provider.d.ts +14 -0
  19. package/dependencies/service-hub/src/service-hub.d.ts +46 -0
  20. package/dependencies/service-hub/src/util.d.ts +1 -0
  21. package/dependencies/text-buffer/index.d.ts +1 -0
  22. package/dependencies/text-buffer/src/display-marker-layer.d.ts +182 -0
  23. package/dependencies/text-buffer/src/display-marker.d.ts +232 -0
  24. package/dependencies/text-buffer/src/helpers.d.ts +11 -0
  25. package/dependencies/text-buffer/src/marker-layer.d.ts +117 -0
  26. package/dependencies/text-buffer/src/marker.d.ts +207 -0
  27. package/dependencies/text-buffer/src/point.d.ts +102 -0
  28. package/dependencies/text-buffer/src/range.d.ts +141 -0
  29. package/dependencies/text-buffer/src/text-buffer.d.ts +759 -0
  30. package/index.d.ts +72 -0
  31. package/linter/config.d.ts +26 -0
  32. package/linter/index.d.ts +108 -0
  33. package/package.json +61 -0
  34. package/src/atom-environment.d.ts +361 -0
  35. package/src/branding.d.ts +19 -0
  36. package/src/buffered-node-process.d.ts +10 -0
  37. package/src/buffered-process.d.ts +88 -0
  38. package/src/clipboard.d.ts +14 -0
  39. package/src/color.d.ts +11 -0
  40. package/src/command-registry.d.ts +118 -0
  41. package/src/config-schema.d.ts +271 -0
  42. package/src/config.d.ts +168 -0
  43. package/src/context-menu-manager.d.ts +65 -0
  44. package/src/cursor.d.ts +252 -0
  45. package/src/decoration.d.ts +156 -0
  46. package/src/deserializer-manager.d.ts +15 -0
  47. package/src/dock.d.ts +121 -0
  48. package/src/get-window-load-settings.d.ts +26 -0
  49. package/src/git-repository.d.ts +174 -0
  50. package/src/grammar-registry.d.ts +241 -0
  51. package/src/gutter.d.ts +118 -0
  52. package/src/history-manager.d.ts +28 -0
  53. package/src/keymap-extensions.d.ts +190 -0
  54. package/src/language-mode.d.ts +314 -0
  55. package/src/layer-decoration.d.ts +31 -0
  56. package/src/menu-manager.d.ts +24 -0
  57. package/src/notification-manager.d.ts +37 -0
  58. package/src/notification.d.ts +79 -0
  59. package/src/other-types.d.ts +283 -0
  60. package/src/package-manager.d.ts +103 -0
  61. package/src/package.d.ts +33 -0
  62. package/src/pane.d.ts +604 -0
  63. package/src/panel.d.ts +38 -0
  64. package/src/path-watcher.d.ts +35 -0
  65. package/src/project.d.ts +110 -0
  66. package/src/scope-descriptor.d.ts +8 -0
  67. package/src/selection.d.ts +341 -0
  68. package/src/style-manager.d.ts +68 -0
  69. package/src/task.d.ts +38 -0
  70. package/src/text-editor-component.d.ts +15 -0
  71. package/src/text-editor-element.d.ts +48 -0
  72. package/src/text-editor-registry.d.ts +48 -0
  73. package/src/text-editor.d.ts +1416 -0
  74. package/src/theme-manager.d.ts +29 -0
  75. package/src/tooltip-manager.d.ts +42 -0
  76. package/src/tooltip.d.ts +63 -0
  77. package/src/ui.d.ts +101 -0
  78. package/src/view-registry.d.ts +34 -0
  79. package/src/wasm-tree-sitter-grammar.d.ts +305 -0
  80. package/src/wasm-tree-sitter-language-mode.d.ts +294 -0
  81. package/src/workspace-center.d.ts +117 -0
  82. package/src/workspace.d.ts +485 -0
  83. package/status-bar/config.d.ts +23 -0
  84. package/status-bar/index.d.ts +51 -0
  85. package/tool-bar/config.d.ts +20 -0
  86. package/tool-bar/index.d.ts +235 -0
  87. package/tsconfig.json +8 -0
@@ -0,0 +1,759 @@
1
+ import { ReadStream, WriteStream } from "fs";
2
+ import {
3
+ Disposable,
4
+ FileSavedEvent,
5
+ HandleableErrorEvent,
6
+ HistoryTransactionOptions,
7
+ HistoryTraversalOptions,
8
+ LanguageMode,
9
+ TextEditOptions
10
+ } from "../../../index";
11
+ import {
12
+ FindMarkerOptions,
13
+ Marker,
14
+ MarkerLayer,
15
+ Point,
16
+ PointCompatible,
17
+ Range,
18
+ RangeCompatible,
19
+ TextChange,
20
+ } from "./text-buffer";
21
+
22
+ export * from "./display-marker";
23
+ export * from "./display-marker-layer";
24
+ export * from "./helpers";
25
+ export * from "./marker";
26
+ export * from "./marker-layer";
27
+ export * from "./point";
28
+ export * from "./range";
29
+
30
+ /**
31
+ * A mutable text container with undo/redo support and the ability to annotate
32
+ * logical regions in the text.
33
+ */
34
+ export class TextBuffer {
35
+ /** The unique identifier for this buffer. */
36
+ readonly id: string;
37
+
38
+ /** The number of retainers for the buffer. */
39
+ readonly refcount: number;
40
+
41
+ /** Whether or not the bufffer has been destroyed. */
42
+ readonly destroyed: boolean;
43
+
44
+ /** Create a new buffer backed by the given file path. */
45
+ static load(filePath: string | TextBufferFileBackend, params?: BufferLoadOptions): Promise<TextBuffer>;
46
+
47
+ /**
48
+ * Create a new buffer backed by the given file path.
49
+ *
50
+ * For better performance, use {@link TextBuffer.load} instead.
51
+ */
52
+ static loadSync(filePath: string, params?: BufferLoadOptions): TextBuffer;
53
+
54
+ /**
55
+ * Restore a TextBuffer based on an earlier state created using the
56
+ * {@link TextBuffer#serialize} method.
57
+ */
58
+ static deserialize(params: object): Promise<TextBuffer>;
59
+
60
+ /** Create a new buffer with the given starting text. */
61
+ constructor(text: string);
62
+ /** Create a new buffer with the given params. */
63
+ constructor(params?: {
64
+ /** The initial string text of the buffer. */
65
+ text?: string | undefined;
66
+ /**
67
+ * A function that returns a Boolean indicating whether the buffer should
68
+ * be destroyed if its file is deleted.
69
+ */
70
+ shouldDestroyOnFileDelete?(): boolean;
71
+ });
72
+
73
+ /** Returns a plain JavaScript object representation of the TextBuffer. */
74
+ serialize(options?: { markerLayers?: boolean | undefined; history?: boolean | undefined }): object;
75
+
76
+ /** Returns the unique identifier for this buffer. */
77
+ getId(): string;
78
+
79
+ // Event Subscription
80
+ /**
81
+ * Invokes the given callback synchronously before the content of the buffer
82
+ * changes.
83
+ */
84
+ onWillChange(callback: (event: BufferChangingEvent) => void): Disposable;
85
+
86
+ /**
87
+ * Invokes the given callback synchronously when the content of the buffer
88
+ * changes. Fires after every single change, even within a transaction.
89
+ *
90
+ * Do not use this in your package unless you absolutely must — and, if so,
91
+ * try very hard to minimize the work done within your callback. It is much
92
+ * better to subscribe to {@link onDidChangeText} (which operates at the
93
+ * transaction level) or, better yet, {@link onDidStopChanging} (which waits
94
+ * until the user has stopped typing for a small amount of time).
95
+ */
96
+ onDidChange(callback: (event: BufferChangedEvent) => void): Disposable;
97
+
98
+ /**
99
+ * Invokes the given callback synchronously when a transaction finishes with a
100
+ * list of all the changes in the transaction.
101
+ */
102
+ onDidChangeText(callback: (event: BufferStoppedChangingEvent) => void): Disposable;
103
+
104
+ /**
105
+ * Invokes the given callback asynchronously following one or more changes
106
+ * after {@link getStoppedChangingDelay} milliseconds elapse without an
107
+ * additional change.
108
+ */
109
+ onDidStopChanging(callback: (event: BufferStoppedChangingEvent) => void): Disposable;
110
+
111
+ /**
112
+ * Invokes the given callback when the in-memory contents of the buffer
113
+ * become in conflict with the contents of the file on disk.
114
+ */
115
+ onDidConflict(callback: () => void): Disposable;
116
+
117
+ /** Invokes the given callback if the value of {@link isModified} changes. */
118
+ onDidChangeModified(callback: (modified: boolean) => void): Disposable;
119
+
120
+ /**
121
+ * Invokes the given callback when all marker {@link onDidChange} observers
122
+ * have been notified following a change to the buffer.
123
+ */
124
+ onDidUpdateMarkers(callback: () => void): Disposable;
125
+
126
+ /**
127
+ * Invokes the given callback when a marker is created.
128
+ */
129
+ onDidCreateMarker(callback: (marker: Marker) => void): Disposable;
130
+
131
+ /** Invokes the given callback when the value of {@link getPath} changes. */
132
+ onDidChangePath(callback: (path: string) => void): Disposable;
133
+
134
+ /**
135
+ * Invokes the given callback when the value of {@link getEncoding} changes.
136
+ */
137
+ onDidChangeEncoding(callback: (encoding: string) => void): Disposable;
138
+
139
+ /**
140
+ * Invokes the given callback before the buffer is saved to disk. If the given
141
+ * callback returns a promise, then the buffer will not be saved until the
142
+ * promise resolves.
143
+ */
144
+ onWillSave(callback: () => Promise<void> | void): Disposable;
145
+
146
+ /** Invokes the given callback after the buffer is saved to disk. */
147
+ onDidSave(callback: (event: FileSavedEvent) => void): Disposable;
148
+
149
+ /**
150
+ * Invokes the given callback after the file backing the buffer is deleted.
151
+ */
152
+ onDidDelete(callback: () => void): Disposable;
153
+
154
+ /**
155
+ * Invokes the given callback before the buffer is reloaded from the contents
156
+ * of its file on disk.
157
+ */
158
+ onWillReload(callback: () => void): Disposable;
159
+
160
+ /**
161
+ * Invokes the given callback after the buffer is reloaded from the contents
162
+ * of its file on disk.
163
+ */
164
+ onDidReload(callback: () => void): Disposable;
165
+
166
+ /** Invokes the given callback when the buffer is destroyed. */
167
+ onDidDestroy(callback: () => void): Disposable;
168
+
169
+ /** Invokes the given callback when there is an error in watching the file. */
170
+ onWillThrowWatchError(callback: (errorObject: HandleableErrorEvent) => void): Disposable;
171
+
172
+ /**
173
+ * Get the number of milliseconds that will elapse without a change before
174
+ * {@link onDidStopChanging} observers are invoked following a change.
175
+ */
176
+ getStoppedChangingDelay(): number;
177
+
178
+ // File Details
179
+
180
+ /**
181
+ * Determine if the in-memory contents of the buffer differ from its contents
182
+ * on disk.
183
+ *
184
+ * If the buffer is unsaved, always returns true unless the buffer is empty.
185
+ */
186
+ isModified(): boolean;
187
+
188
+ /**
189
+ * Determine if the in-memory contents of the buffer conflict with the
190
+ * on-disk contents of its associated file.
191
+ */
192
+ isInConflict(): boolean;
193
+
194
+ /** Get the path of the associated file. */
195
+ getPath(): string | undefined;
196
+
197
+ /** Set the path for the buffer's associated file. */
198
+ setPath(filePath: string): void;
199
+
200
+ /**
201
+ * Experimental: Set a custom {@link TextBufferFileBackend} object as the
202
+ * buffer's backing store.
203
+ */
204
+ setFile(fileBackend: TextBufferFileBackend): void;
205
+
206
+ /** Sets the character set encoding for this buffer. */
207
+ setEncoding(encoding: string): void;
208
+
209
+ /** Returns the string encoding of this buffer. */
210
+ getEncoding(): string;
211
+
212
+ /** Get the path of the associated file. */
213
+ getUri(): string;
214
+
215
+ // Reading Text
216
+ /** Determine whether the buffer is empty. */
217
+ isEmpty(): boolean;
218
+
219
+ /**
220
+ * Get the entire text of the buffer. Avoid using this unless you know that
221
+ * the buffer's text is reasonably short.
222
+ */
223
+ getText(): string;
224
+
225
+ /** Get the text in a range. */
226
+ getTextInRange(range: RangeCompatible): string;
227
+
228
+ /** Get the text of all lines in the buffer, without their line endings. */
229
+ getLines(): string[];
230
+
231
+ /** Get the text of the last line of the buffer, without its line ending. */
232
+ getLastLine(): string;
233
+
234
+ /**
235
+ * Get the text of the line at the given 0-indexed row, without its line
236
+ * ending.
237
+ *
238
+ * @param row A number representing the row.
239
+ */
240
+ lineForRow(row: number): string | undefined;
241
+
242
+ /** Get the line ending for the given 0-indexed row. */
243
+ lineEndingForRow(row: number): string | undefined;
244
+
245
+ /**
246
+ * Get the length of the line for the given 0-indexed row _without_ its line
247
+ * ending.
248
+ */
249
+ lineLengthForRow(row: number): number;
250
+
251
+ /** Determine if the given row contains only whitespace. */
252
+ isRowBlank(row: number): boolean;
253
+
254
+ /**
255
+ * Given a row, find the first preceding row that's not blank.
256
+ *
257
+ * Returns a number or `null` if there's no preceding non-blank row.
258
+ */
259
+ previousNonBlankRow(startRow: number): number | null;
260
+
261
+ /**
262
+ * Given a row, find the next row that's not blank.
263
+ *
264
+ * Returns a number or `null` if there's no next non-blank row.
265
+ */
266
+ nextNonBlankRow(startRow: number): number | null;
267
+
268
+ /**
269
+ * Return `true` if the buffer contains any astral-plane Unicode characters
270
+ * that are encoded as surrogate pairs.
271
+ */
272
+ hasAstral(): boolean;
273
+
274
+ // Mutating Text
275
+
276
+ /** Replace the entire contents of the buffer with the given text. */
277
+ setText(text: string): Range;
278
+
279
+ /**
280
+ * Replace the current buffer contents by applying a diff based on the given
281
+ * text.
282
+ */
283
+ setTextViaDiff(text: string): void;
284
+
285
+ /** Set the text in the given range. */
286
+ setTextInRange(range: RangeCompatible, text: string, options?: TextEditOptions): Range;
287
+
288
+ /** Insert text at the given position. */
289
+ insert(position: PointCompatible, text: string, options?: TextEditOptions): Range;
290
+
291
+ /** Append text to the end of the buffer. */
292
+ append(text: string, options?: TextEditOptions): Range;
293
+
294
+ /** Delete the text in the given range. */
295
+ delete(range: RangeCompatible): Range;
296
+
297
+ /**
298
+ * Delete the line associated with a specified 0-indexed row.
299
+ *
300
+ * @param row A number representing the row to delete.
301
+ */
302
+ deleteRow(row: number): Range;
303
+
304
+ /**
305
+ * Delete the lines associated with the specified 0-indexed row range.
306
+ *
307
+ * If the row range is out of bounds, it will be clipped. If the `startRow`
308
+ * is greater than the `endRow`, they will be reordered.
309
+ */
310
+ deleteRows(startRow: number, endRow: number): Range;
311
+
312
+ // Markers
313
+
314
+ /** Create a layer to contain a set of related markers. */
315
+ addMarkerLayer(
316
+ options?: {
317
+ maintainHistory?: boolean | undefined;
318
+ persistent?: boolean | undefined;
319
+ role?: string | undefined;
320
+ },
321
+ ): MarkerLayer;
322
+
323
+ /**
324
+ * Get a MarkerLayer by ID.
325
+ *
326
+ * Returns a MarkerLayer or `undefined` if no layer exists with the given ID.
327
+ */
328
+ getMarkerLayer(id: string): MarkerLayer | undefined;
329
+
330
+ /** Get the default MarkerLayer. */
331
+ getDefaultMarkerLayer(): MarkerLayer;
332
+
333
+ /** Create a marker with the given range in the default marker layer. */
334
+ markRange(
335
+ range: RangeCompatible,
336
+ properties?: {
337
+ reversed?: boolean | undefined;
338
+ invalidate?: "never" | "surround" | "overlap" | "inside" | "touch" | undefined;
339
+ exclusive?: boolean | undefined;
340
+ },
341
+ ): Marker;
342
+
343
+ /**
344
+ * Create a marker at the given position with no tail in the default marker
345
+ * layer.
346
+ */
347
+ markPosition(
348
+ position: PointCompatible,
349
+ options?: {
350
+ invalidate?: "never" | "surround" | "overlap" | "inside" | "touch" | undefined;
351
+ exclusive?: boolean | undefined;
352
+ },
353
+ ): Marker;
354
+
355
+ /** Get all existing markers on the default marker layer. */
356
+ getMarkers(): Marker[];
357
+
358
+ /** Get an existing marker by its id from the default marker layer. */
359
+ getMarker(id: number): Marker;
360
+
361
+ /**
362
+ * Find markers conforming to the given parameters in the default marker
363
+ * layer.
364
+ */
365
+ findMarkers(params: FindMarkerOptions): Marker[];
366
+
367
+ /** Get the number of markers in the default marker layer. */
368
+ getMarkerCount(): number;
369
+
370
+ // History
371
+
372
+ /**
373
+ * Undo the last operation. If a transaction is in progress, aborts it.
374
+ *
375
+ * @return A boolean of whether or not a change was made.
376
+ */
377
+ undo(options?: HistoryTraversalOptions): boolean;
378
+
379
+ /**
380
+ * Redo the last operation.
381
+ *
382
+ * @return A boolean of whether or not a change was made.
383
+ */
384
+ redo(options?: HistoryTraversalOptions): boolean;
385
+
386
+ /** Batch multiple operations as a single undo/redo step. */
387
+ transact<T>(
388
+ optionsOrInterval: number | ({ groupingInterval?: number | undefined } & HistoryTransactionOptions),
389
+ fn: () => T,
390
+ ): T;
391
+ /** Batch multiple operations as a single undo/redo step. */
392
+ transact<T>(fn: () => T): T;
393
+
394
+ /**
395
+ * Abort the currently running transaction.
396
+ *
397
+ * Only intended to be called within the `fn` option to {@link transact}.
398
+ */
399
+ abortTransaction(): void;
400
+
401
+ /** Clear the undo stack. */
402
+ clearUndoStack(): void;
403
+
404
+ /**
405
+ * Create a pointer to the current state of the buffer for use with
406
+ * {@link revertToCheckpoint} and {@link groupChangesSinceCheckpoint}.
407
+ *
408
+ * @return A checkpoint ID value.
409
+ */
410
+ createCheckpoint(options?: HistoryTransactionOptions): number;
411
+
412
+ /**
413
+ * Revert the buffer to the state it was in when the given checkpoint was
414
+ * created.
415
+ *
416
+ * @return A boolean indicating whether the operation succeeded.
417
+ */
418
+ revertToCheckpoint(checkpoint: number, options?: HistoryTraversalOptions): boolean;
419
+
420
+ /**
421
+ * Group all changes since the given checkpoint into a single transaction for
422
+ * purposes of undo/redo.
423
+ *
424
+ * @return A boolean indicating whether the operation succeeded.
425
+ */
426
+ groupChangesSinceCheckpoint(checkpoint: number, options?: HistoryTransactionOptions): boolean;
427
+
428
+ /**
429
+ * Group the last two text changes for purposes of undo/redo.
430
+ *
431
+ * This operation will only succeed if there are two changes on the undo
432
+ * stack. It will not group past the beginning of an open transaction.
433
+ *
434
+ * @return A boolean indicating whether the operation succeeded.
435
+ */
436
+ groupLastChanges(): boolean;
437
+
438
+ /**
439
+ * Returns a list of changes since the given checkpoint.
440
+ *
441
+ * If the given checkpoint is no longer present in the undo history, this
442
+ * method will return an empty Array.
443
+ */
444
+ getChangesSinceCheckpoint(
445
+ checkpoint: number,
446
+ ): Array<{
447
+ /** A Point representing where the change started. */
448
+ start: Point;
449
+
450
+ /** A Point representing the replaced extent. */
451
+ oldExtent: Point;
452
+
453
+ /** A Point representing the replacement extent. */
454
+ newExtent: Point;
455
+
456
+ /** A String representing the replacement text. */
457
+ newText: string;
458
+ }>;
459
+
460
+ // Search and Replace
461
+
462
+ /**
463
+ * Scan regular expression matches in the entire buffer, calling the given
464
+ * iterator function on each match.
465
+ */
466
+ scan(regex: RegExp, iterator: (params: BufferScanResult) => void): void;
467
+ /**
468
+ * Scan regular expression matches in the entire buffer, calling the given
469
+ * iterator function on each match.
470
+ */
471
+ scan(regex: RegExp, options: ScanContextOptions, iterator: (params: ContextualBufferScanResult) => void): void;
472
+
473
+ /**
474
+ * Scan regular expression matches in the entire buffer in reverse order,
475
+ * calling the given iterator function on each match.
476
+ */
477
+ backwardsScan(regex: RegExp, iterator: (params: BufferScanResult) => void): void;
478
+ /**
479
+ * Scan regular expression matches in the entire buffer in reverse order,
480
+ * calling the given iterator function on each match.
481
+ */
482
+ backwardsScan(
483
+ regex: RegExp,
484
+ options: ScanContextOptions,
485
+ iterator: (params: ContextualBufferScanResult) => void,
486
+ ): void;
487
+
488
+ /**
489
+ * Scan regular expression matches in a given range , calling the given
490
+ * iterator function on each match.
491
+ */
492
+ scanInRange(regex: RegExp, range: RangeCompatible, iterator: (params: BufferScanResult) => void): void;
493
+ /**
494
+ * Scan regular expression matches in a given range , calling the given
495
+ * iterator function on each match.
496
+ */
497
+ scanInRange(
498
+ regex: RegExp,
499
+ range: RangeCompatible,
500
+ options: ScanContextOptions,
501
+ iterator: (params: ContextualBufferScanResult) => void,
502
+ ): void;
503
+
504
+ /**
505
+ * Scan regular expression matches in a given range in reverse order, calling
506
+ * the given iterator function on each match.
507
+ */
508
+ backwardsScanInRange(regex: RegExp, range: RangeCompatible, iterator: (params: BufferScanResult) => void): void;
509
+ /**
510
+ * Scan regular expression matches in a given range in reverse order, calling
511
+ * the given iterator function on each match.
512
+ */
513
+ backwardsScanInRange(
514
+ regex: RegExp,
515
+ range: RangeCompatible,
516
+ options: ScanContextOptions,
517
+ iterator: (params: ContextualBufferScanResult) => void,
518
+ ): void;
519
+
520
+ /** Replace all regular expression matches in the entire buffer. */
521
+ replace(regex: RegExp, replacementText: string): number;
522
+
523
+ // Buffer Range Details
524
+ /** Get the range spanning from [0, 0] to ::getEndPosition. */
525
+ getRange(): Range;
526
+
527
+ /** Get the number of lines in the buffer. */
528
+ getLineCount(): number;
529
+
530
+ /** Get the last 0-indexed row in the buffer. */
531
+ getLastRow(): number;
532
+
533
+ /** Get the first position in the buffer, which is always [0, 0]. */
534
+ getFirstPosition(): Point;
535
+
536
+ /**
537
+ * Get the maximal position in the buffer, where new text would be appended.
538
+ */
539
+ getEndPosition(): Point;
540
+
541
+ /** Get the length of the buffer's text. */
542
+ getLength(): number;
543
+
544
+ /** Get the length of the buffer in characters. */
545
+ getMaxCharacterIndex(): number;
546
+
547
+ /**
548
+ * Get the range for the given row.
549
+ *
550
+ * @param row A number representing a 0-indexed row.
551
+ * @param includeNewline A boolean indicating whether or not to include the
552
+ * newline, which results in a range that extends to the start of the next
553
+ * line. (default: `false`)
554
+ */
555
+ rangeForRow(row: number, includeNewline?: boolean): Range;
556
+
557
+ /**
558
+ * Convert a position in the buffer in row/column coordinates to an absolute
559
+ * character offset, inclusive of line ending characters.
560
+ */
561
+ characterIndexForPosition(position: PointCompatible): number;
562
+
563
+ /**
564
+ * Convert an absolute character offset, inclusive of newlines, to a position
565
+ * in the buffer in row/column coordinates.
566
+ */
567
+ positionForCharacterIndex(offset: number): Point;
568
+
569
+ /** Clip the given range so it starts and ends at valid positions. */
570
+ clipRange(range: RangeCompatible): Range;
571
+
572
+ /** Clip the given point so it is at a valid position in the buffer. */
573
+ clipPosition(position: PointCompatible): Point;
574
+
575
+ // Buffer Operations
576
+ /** Save the buffer. */
577
+ save(): Promise<void>;
578
+
579
+ /** Save the buffer at a specific path. */
580
+ saveAs(filePath: string): Promise<void>;
581
+
582
+ /** Reload the buffer's contents from disk. */
583
+ reload(): void;
584
+
585
+ /** Destroy the buffer, even if there are retainers for it. */
586
+ destroy(): void;
587
+
588
+ /** Returns whether or not this buffer is alive. */
589
+ isAlive(): boolean;
590
+
591
+ /** Returns whether or not this buffer has been destroyed. */
592
+ isDestroyed(): boolean;
593
+
594
+ /** Returns whether or not this buffer has a retainer. */
595
+ isRetained(): boolean;
596
+
597
+ /**
598
+ * Places a retainer on the buffer, preventing its destruction until the
599
+ * final retainer has called {@link release}.
600
+ */
601
+ retain(): TextBuffer;
602
+
603
+ /**
604
+ * Releases a retainer on the buffer, destroying the buffer if there are no
605
+ * additional retainers.
606
+ */
607
+ release(): TextBuffer;
608
+
609
+ /** Identifies if the buffer belongs to multiple editors. */
610
+ hasMultipleEditors(): boolean;
611
+
612
+ // Language modes
613
+
614
+ /** Returns the current {@link LanguageMode} for the buffer. */
615
+ getLanguageMode(): LanguageMode;
616
+
617
+ /** Sets the buffer's {@link LanguageMode}. */
618
+ setLanguageMode(languageMode: LanguageMode): void;
619
+
620
+ /**
621
+ * Invokes the given callback when the buffer's {@link LanguageMode} changes.
622
+ */
623
+ onDidChangeLanguageMode(
624
+ callback: (languageMode: LanguageMode) => unknown
625
+ ): Disposable;
626
+ }
627
+
628
+ export interface TextBufferFileBackend {
629
+ /** A {Function} that returns the {String} path to the file. */
630
+ getPath(): string;
631
+
632
+ /**
633
+ * Returns a `Readable` stream that can be used to load the file's content.
634
+ */
635
+ createReadStream(): ReadStream;
636
+
637
+ /**
638
+ * Returns a `Writable` stream that can be used to save content to the file.
639
+ */
640
+ createWriteStream(): WriteStream;
641
+
642
+ /** Returns `true` if the file exists, `false` otherwise. */
643
+ existsSync(): boolean;
644
+
645
+ /**
646
+ * Add a listener that will be called when the file changes.
647
+ */
648
+ onDidChange?(callback: () => void): Disposable;
649
+
650
+ /**
651
+ * Add a listener that will be called when the file is deleted.
652
+ */
653
+ onDidDelete?(callback: () => void): Disposable;
654
+
655
+ /**
656
+ * Add a listener that will be called when the file is renamed.
657
+ */
658
+ onDidRename?(callback: () => void): Disposable;
659
+ }
660
+
661
+ /** The event associated with {@link TextBuffer#onWillChange}. */
662
+ export interface BufferChangingEvent {
663
+ /** Range of the old text. */
664
+ oldRange: Range;
665
+ }
666
+
667
+ /** The event associated with {@link TextBuffer#onDidChange}. */
668
+ export interface BufferChangedEvent {
669
+ /**
670
+ * An array of objects summarizing the aggregated changes that occurred
671
+ * during the transaction.
672
+ */
673
+ changes: Array<{
674
+ /**
675
+ * The Range of the deleted text in the contents of the buffer as it
676
+ * existed before the batch of changes reported by this event.
677
+ */
678
+ oldRange: Range;
679
+
680
+ /** The Range of the inserted text in the current contents of the buffer. */
681
+ newRange: Range;
682
+ }>;
683
+
684
+ /** Range of the old text. */
685
+ oldRange: Range;
686
+
687
+ /** Range of the new text. */
688
+ newRange: Range;
689
+
690
+ /** String containing the text that was replaced. */
691
+ oldText: string;
692
+
693
+ /** String containing the text that was inserted. */
694
+ newText: string;
695
+ }
696
+
697
+ /** The event associated with {@link TextBuffer#onDidStopChanging}. */
698
+ export interface BufferStoppedChangingEvent {
699
+ changes: TextChange[];
700
+ }
701
+
702
+ /**
703
+ * The options that may be passed to {@link TextBuffer.load} and
704
+ * {@link TextBuffer.loadSync}.
705
+ */
706
+ export interface BufferLoadOptions {
707
+ /** The file's encoding. */
708
+ encoding?: string | undefined;
709
+
710
+ /**
711
+ * A function that returns a boolean indicating whether the buffer should be
712
+ * destroyed if its file is deleted.
713
+ */
714
+ shouldDestroyOnFileDelete?(): boolean;
715
+ }
716
+
717
+ /**
718
+ * The result object given during {@link TextBuffer#scan} and
719
+ * {@link TextBuffer#scanInRange}, as well as the "backwards" versions of those
720
+ * methods.
721
+ */
722
+ export interface BufferScanResult {
723
+ buffer: TextBuffer;
724
+ lineText: string;
725
+ match: RegExpExecArray;
726
+ matchText: string;
727
+ range: Range;
728
+ replace(replacementText: string): void;
729
+ stop(): void;
730
+ stopped: boolean;
731
+ }
732
+
733
+ /**
734
+ * Additional properties that are included in {@link BufferScanResult} if the
735
+ * contextual options in {@link ScanContextOptions} were specified.
736
+ */
737
+ export interface ContextualBufferScanResult extends BufferScanResult {
738
+ leadingContextLines: string[];
739
+ trailingContextLines: string[];
740
+ }
741
+
742
+ /**
743
+ * Additional options that may be passed to {@link TextBuffer#scan} and
744
+ * {@link TextBuffer#scanInRange}, as well as the "backwards" versions of those
745
+ * methods.
746
+ */
747
+ export interface ScanContextOptions {
748
+ /**
749
+ * The number of lines before the matched line to include in the results
750
+ * object.
751
+ */
752
+ leadingContextLineCount?: number | undefined;
753
+
754
+ /**
755
+ * The number of lines after the matched line to include in the results
756
+ * object.
757
+ */
758
+ trailingContextLineCount?: number | undefined;
759
+ }