@fresh-editor/fresh-editor 0.2.23 → 0.2.25

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
  /**
@@ -1094,11 +1129,16 @@ interface EditorAPI {
1094
1129
  */
1095
1130
  getTempDir(): string;
1096
1131
  /**
1097
- * Get current config as JS object
1132
+ * Get current config as JS object.
1133
+ *
1134
+ * The snapshot holds an `Arc<serde_json::Value>` that was serialized
1135
+ * on the editor side the last time the underlying `Arc<Config>`
1136
+ * changed. Cloning the Arc inside the read lock is a refcount bump;
1137
+ * the actual walk into the JS runtime happens outside the lock.
1098
1138
  */
1099
1139
  getConfig(): unknown;
1100
1140
  /**
1101
- * Get user config as JS object
1141
+ * Get user config as JS object. Same Arc-clone pattern as `get_config`.
1102
1142
  */
1103
1143
  getUserConfig(): unknown;
1104
1144
  /**
@@ -1143,6 +1183,12 @@ interface EditorAPI {
1143
1183
  */
1144
1184
  getConfigDir(): string;
1145
1185
  /**
1186
+ * Get the persistent data directory path (DirectoryContext::data_dir).
1187
+ * Intended for plugin state that should outlive a single session — e.g.
1188
+ * review-diff comments keyed off git state.
1189
+ */
1190
+ getDataDir(): string;
1191
+ /**
1146
1192
  * Get themes directory path
1147
1193
  */
1148
1194
  getThemesDir(): string;
@@ -1276,6 +1322,17 @@ interface EditorAPI {
1276
1322
  */
1277
1323
  clearConcealsInRange(bufferId: number, start: number, end: number): boolean;
1278
1324
  /**
1325
+ * Add a collapsed fold range. Hides bytes [start, end) from
1326
+ * rendering — the line containing `start - 1` (the fold "header")
1327
+ * stays visible, while subsequent lines covered by the range are
1328
+ * skipped.
1329
+ */
1330
+ addFold(bufferId: number, start: number, end: number, placeholder?: string): boolean;
1331
+ /**
1332
+ * Clear every collapsed fold range on the buffer.
1333
+ */
1334
+ clearFolds(bufferId: number): boolean;
1335
+ /**
1279
1336
  * Add a soft break point for marker-based line wrapping
1280
1337
  */
1281
1338
  addSoftBreak(bufferId: number, namespace: string, position: number, indent: number): boolean;
@@ -1336,8 +1393,14 @@ interface EditorAPI {
1336
1393
  clearVirtualTextNamespace(bufferId: number, namespace: string): boolean;
1337
1394
  /**
1338
1395
  * Add a virtual line (full line above/below a position)
1396
+ *
1397
+ * The `options` object accepts:
1398
+ * * `fg`, `bg` — either an `[r, g, b]` array (each `0..=255`) or a
1399
+ * theme-key string (e.g. `"editor.line_number_fg"`). Theme keys
1400
+ * are resolved at render time so the line follows theme changes.
1401
+ * Both default to `null` (no foreground / transparent background).
1339
1402
  */
1340
- 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;
1403
+ addVirtualLine(bufferId: number, position: number, text: string, options: Record<string, unknown>, above: boolean, namespace: string, priority: number): boolean;
1341
1404
  /**
1342
1405
  * Show a prompt and wait for user input (async)
1343
1406
  * Returns the user input or null if cancelled
@@ -1361,7 +1424,7 @@ interface EditorAPI {
1361
1424
  /**
1362
1425
  * Define a buffer mode (takes bindings as array of [key, command] pairs)
1363
1426
  */
1364
- defineMode(name: string, bindingsArr: string[][], readOnly?: boolean, allowTextInput?: boolean): boolean;
1427
+ defineMode(name: string, bindingsArr: string[][], readOnly?: boolean, allowTextInput?: boolean, inheritNormalBindings?: boolean): boolean;
1365
1428
  /**
1366
1429
  * Set the global editor mode
1367
1430
  */
@@ -1411,6 +1474,15 @@ interface EditorAPI {
1411
1474
  */
1412
1475
  setBufferCursor(bufferId: number, position: number): boolean;
1413
1476
  /**
1477
+ * Toggle whether the editor draws a native caret in this buffer.
1478
+ *
1479
+ * Buffer-group panel buffers default to `show_cursors = false`, which
1480
+ * also blocks all native movement actions in `action_to_events`. Plugins
1481
+ * that want native cursor motion in a panel (e.g. magit-style row
1482
+ * navigation) call this with `true` after `createBufferGroup` returns.
1483
+ */
1484
+ setBufferShowCursors(bufferId: number, show: boolean): boolean;
1485
+ /**
1414
1486
  * Set a line indicator in the gutter
1415
1487
  */
1416
1488
  setLineIndicator(bufferId: number, line: number, namespace: string, symbol: string, r: number, g: number, b: number, priority: number): boolean;