@nghyane/arcane-tui 0.1.12 → 0.1.13

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@nghyane/arcane-tui",
4
- "version": "0.1.12",
4
+ "version": "0.1.13",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://github.com/nghyane/arcane",
7
7
  "author": "Can Bölük",
@@ -36,7 +36,7 @@
36
36
  "test": "bun test test/*.test.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@nghyane/arcane-natives": "^0.1.8",
39
+ "@nghyane/arcane-natives": "^0.1.9",
40
40
  "@nghyane/arcane-utils": "^0.1.7",
41
41
  "@types/mime-types": "^3.0.1",
42
42
  "chalk": "^5.6.2",
@@ -365,6 +365,10 @@ export class Editor implements Component, Focusable {
365
365
  onAltEnter?: (text: string) => void;
366
366
  onChange?: (text: string) => void;
367
367
  onAutocompleteCancel?: () => void;
368
+ /** Called before processing a bracketed paste. Return true to suppress default paste handling. */
369
+ onPaste?: (text: string) => boolean;
370
+ /** Apply syntax highlighting to a display line after cursor rendering. Must preserve visible width. */
371
+ onHighlightLine?: (text: string) => string;
368
372
  disableSubmit: boolean = false;
369
373
 
370
374
  // Custom top border (for status line integration)
@@ -653,6 +657,11 @@ export class Editor implements Component, Focusable {
653
657
  }
654
658
  }
655
659
 
660
+ // Apply optional syntax highlighting
661
+ if (this.onHighlightLine) {
662
+ displayText = this.onHighlightLine(displayText);
663
+ }
664
+
656
665
  // All lines have consistent borders based on padding
657
666
  const isLastLine = layoutLine === visibleLayoutLines[visibleLayoutLines.length - 1];
658
667
  const linePad = padding(Math.max(0, lineContentWidth - displayWidth));
@@ -1245,6 +1254,8 @@ export class Editor implements Component, Focusable {
1245
1254
  }
1246
1255
 
1247
1256
  #handlePaste(pastedText: string): void {
1257
+ if (this.onPaste?.(pastedText)) return;
1258
+
1248
1259
  this.#historyIndex = -1; // Exit history browsing mode
1249
1260
  this.#resetKillSequence();
1250
1261
  this.#recordUndoState();