@fresh-editor/fresh-editor 0.2.22 → 0.2.24

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.
@@ -44,6 +44,32 @@ interface ProcessHandle<T> extends PromiseLike<T> {
44
44
  type BufferId = number;
45
45
  /** Split identifier */
46
46
  type SplitId = number;
47
+ /**
48
+ * Payload delivered to handlers registered with `editor.on("mouse_click", ...)`.
49
+ *
50
+ * All coordinate fields are in cell (terminal character) units. `buffer_*`
51
+ * fields are `null` when the click did not land in any buffer panel.
52
+ */
53
+ interface MouseClickHookArgs {
54
+ /** Screen column (0-indexed). */
55
+ column: number;
56
+ /** Screen row (0-indexed). */
57
+ row: number;
58
+ /** Mouse button: "left", "right", "middle". */
59
+ button: string;
60
+ /** Modifier keys (e.g. "shift"). */
61
+ modifiers: string;
62
+ /** X offset of the content area the click landed in. */
63
+ content_x: number;
64
+ /** Y offset of the content area the click landed in. */
65
+ content_y: number;
66
+ /** Buffer under the click, or `null` when outside any buffer panel. */
67
+ buffer_id: number | null;
68
+ /** 0-indexed buffer row (line number) of the click, accounting for scroll. */
69
+ buffer_row: number | null;
70
+ /** 0-indexed byte column inside the buffer row. */
71
+ buffer_col: number | null;
72
+ }
47
73
  type TextPropertyEntry = {
48
74
  /**
49
75
  * Text content for this entry
@@ -308,6 +334,15 @@ type BufferInfo = {
308
334
  * The detected language for this buffer (e.g., "rust", "markdown", "text")
309
335
  */
310
336
  language: string;
337
+ /**
338
+ * Whether this tab was opened in "preview" (ephemeral) mode — true when
339
+ * opened via single-click in the file explorer and not yet committed
340
+ * (no edit, no double-click, no tab-click, no layout change). Plugins
341
+ * that react to buffer lifecycle events should generally treat preview
342
+ * buffers as transient; e.g. a diagnostics panel may want to skip
343
+ * refreshing itself for a preview tab.
344
+ */
345
+ is_preview: boolean;
311
346
  };
312
347
  type JsDiagnostic = {
313
348
  /**
@@ -399,9 +434,9 @@ type FileExplorerDecoration = {
399
434
  */
400
435
  symbol: string;
401
436
  /**
402
- * Color as RGB array (rquickjs_serde requires array, not tuple)
437
+ * Color as RGB array or theme key string (e.g., "ui.file_status_added_fg")
403
438
  */
404
- color: [number, number, number];
439
+ color: OverlayColorSpec;
405
440
  /**
406
441
  * Priority for display when multiple decorations exist (higher wins)
407
442
  */
@@ -947,6 +982,17 @@ interface EditorAPI {
947
982
  */
948
983
  scrollToLineCenter(splitId: number, bufferId: number, line: number): boolean;
949
984
  /**
985
+ * Scroll any split/panel showing `buffer_id` so `line` is visible.
986
+ * Unlike `scrollToLineCenter`, this does not require a split id — it
987
+ * updates every split's viewport whose active buffer is the given
988
+ * buffer, including inner leaves of a buffer group. Use this from
989
+ * a panel plugin to keep the user's "selected" row in view after
990
+ * arrow-key navigation (the plugin's own selection state isn't
991
+ * automatically reflected in the buffer cursor, so the core-driven
992
+ * viewport would otherwise stay put).
993
+ */
994
+ scrollBufferToLine(bufferId: number, line: number): boolean;
995
+ /**
950
996
  * Find buffer by file path, returns buffer ID or 0 if not found
951
997
  */
952
998
  findBufferByPath(path: string): number;
@@ -1132,6 +1178,12 @@ interface EditorAPI {
1132
1178
  */
1133
1179
  getConfigDir(): string;
1134
1180
  /**
1181
+ * Get the persistent data directory path (DirectoryContext::data_dir).
1182
+ * Intended for plugin state that should outlive a single session — e.g.
1183
+ * review-diff comments keyed off git state.
1184
+ */
1185
+ getDataDir(): string;
1186
+ /**
1135
1187
  * Get themes directory path
1136
1188
  */
1137
1189
  getThemesDir(): string;
@@ -1265,6 +1317,17 @@ interface EditorAPI {
1265
1317
  */
1266
1318
  clearConcealsInRange(bufferId: number, start: number, end: number): boolean;
1267
1319
  /**
1320
+ * Add a collapsed fold range. Hides bytes [start, end) from
1321
+ * rendering — the line containing `start - 1` (the fold "header")
1322
+ * stays visible, while subsequent lines covered by the range are
1323
+ * skipped.
1324
+ */
1325
+ addFold(bufferId: number, start: number, end: number, placeholder?: string): boolean;
1326
+ /**
1327
+ * Clear every collapsed fold range on the buffer.
1328
+ */
1329
+ clearFolds(bufferId: number): boolean;
1330
+ /**
1268
1331
  * Add a soft break point for marker-based line wrapping
1269
1332
  */
1270
1333
  addSoftBreak(bufferId: number, namespace: string, position: number, indent: number): boolean;
@@ -1325,8 +1388,14 @@ interface EditorAPI {
1325
1388
  clearVirtualTextNamespace(bufferId: number, namespace: string): boolean;
1326
1389
  /**
1327
1390
  * Add a virtual line (full line above/below a position)
1391
+ *
1392
+ * The `options` object accepts:
1393
+ * * `fg`, `bg` — either an `[r, g, b]` array (each `0..=255`) or a
1394
+ * theme-key string (e.g. `"editor.line_number_fg"`). Theme keys
1395
+ * are resolved at render time so the line follows theme changes.
1396
+ * Both default to `null` (no foreground / transparent background).
1328
1397
  */
1329
- addVirtualLine(bufferId: number, position: number, text: string, fgR: number, fgG: number, fgB: number, bgR: number, bgG: number, bgB: number, above: boolean, namespace: string, priority: number): boolean;
1398
+ addVirtualLine(bufferId: number, position: number, text: string, options: Record<string, unknown>, above: boolean, namespace: string, priority: number): boolean;
1330
1399
  /**
1331
1400
  * Show a prompt and wait for user input (async)
1332
1401
  * Returns the user input or null if cancelled
@@ -1350,7 +1419,7 @@ interface EditorAPI {
1350
1419
  /**
1351
1420
  * Define a buffer mode (takes bindings as array of [key, command] pairs)
1352
1421
  */
1353
- defineMode(name: string, bindingsArr: string[][], readOnly?: boolean, allowTextInput?: boolean): boolean;
1422
+ defineMode(name: string, bindingsArr: string[][], readOnly?: boolean, allowTextInput?: boolean, inheritNormalBindings?: boolean): boolean;
1354
1423
  /**
1355
1424
  * Set the global editor mode
1356
1425
  */
@@ -1400,6 +1469,15 @@ interface EditorAPI {
1400
1469
  */
1401
1470
  setBufferCursor(bufferId: number, position: number): boolean;
1402
1471
  /**
1472
+ * Toggle whether the editor draws a native caret in this buffer.
1473
+ *
1474
+ * Buffer-group panel buffers default to `show_cursors = false`, which
1475
+ * also blocks all native movement actions in `action_to_events`. Plugins
1476
+ * that want native cursor motion in a panel (e.g. magit-style row
1477
+ * navigation) call this with `true` after `createBufferGroup` returns.
1478
+ */
1479
+ setBufferShowCursors(bufferId: number, show: boolean): boolean;
1480
+ /**
1403
1481
  * Set a line indicator in the gutter
1404
1482
  */
1405
1483
  setLineIndicator(bufferId: number, line: number, namespace: string, symbol: string, r: number, g: number, b: number, priority: number): boolean;
@@ -1501,6 +1579,18 @@ interface EditorAPI {
1501
1579
  */
1502
1580
  createVirtualBufferInExistingSplit(opts: CreateVirtualBufferInExistingSplitOptions): Promise<VirtualBufferResult>;
1503
1581
  /**
1582
+ * Set the content of a panel within a buffer group
1583
+ */
1584
+ setPanelContent(groupId: number, panelName: string, entriesArr: Record<string, unknown>[]): boolean;
1585
+ /**
1586
+ * Close a buffer group
1587
+ */
1588
+ closeBufferGroup(groupId: number): boolean;
1589
+ /**
1590
+ * Focus a specific panel within a buffer group
1591
+ */
1592
+ focusBufferGroupPanel(groupId: number, panelName: string): boolean;
1593
+ /**
1504
1594
  * Set virtual buffer content (takes array of entry objects)
1505
1595
  *
1506
1596
  * Note: entries should be TextPropertyEntry[] - uses manual parsing for HashMap support