phi-code-tui 0.56.3 → 0.74.0

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 (102) hide show
  1. package/README.md +29 -11
  2. package/dist/index.js +3 -3
  3. package/package.json +2 -2
  4. package/dist/autocomplete.d.ts +0 -50
  5. package/dist/autocomplete.d.ts.map +0 -1
  6. package/dist/autocomplete.js +0 -593
  7. package/dist/autocomplete.js.map +0 -1
  8. package/dist/components/box.d.ts +0 -22
  9. package/dist/components/box.d.ts.map +0 -1
  10. package/dist/components/box.js +0 -99
  11. package/dist/components/box.js.map +0 -1
  12. package/dist/components/cancellable-loader.d.ts +0 -22
  13. package/dist/components/cancellable-loader.d.ts.map +0 -1
  14. package/dist/components/cancellable-loader.js +0 -36
  15. package/dist/components/cancellable-loader.js.map +0 -1
  16. package/dist/components/editor.d.ts +0 -205
  17. package/dist/components/editor.d.ts.map +0 -1
  18. package/dist/components/editor.js +0 -1632
  19. package/dist/components/editor.js.map +0 -1
  20. package/dist/components/image.d.ts +0 -28
  21. package/dist/components/image.d.ts.map +0 -1
  22. package/dist/components/image.js +0 -61
  23. package/dist/components/image.js.map +0 -1
  24. package/dist/components/input.d.ts +0 -37
  25. package/dist/components/input.d.ts.map +0 -1
  26. package/dist/components/input.js +0 -443
  27. package/dist/components/input.js.map +0 -1
  28. package/dist/components/loader.d.ts +0 -21
  29. package/dist/components/loader.d.ts.map +0 -1
  30. package/dist/components/loader.js +0 -46
  31. package/dist/components/loader.js.map +0 -1
  32. package/dist/components/markdown.d.ts +0 -95
  33. package/dist/components/markdown.d.ts.map +0 -1
  34. package/dist/components/markdown.js +0 -641
  35. package/dist/components/markdown.js.map +0 -1
  36. package/dist/components/select-list.d.ts +0 -32
  37. package/dist/components/select-list.d.ts.map +0 -1
  38. package/dist/components/select-list.js +0 -148
  39. package/dist/components/select-list.js.map +0 -1
  40. package/dist/components/settings-list.d.ts +0 -50
  41. package/dist/components/settings-list.d.ts.map +0 -1
  42. package/dist/components/settings-list.js +0 -177
  43. package/dist/components/settings-list.js.map +0 -1
  44. package/dist/components/spacer.d.ts +0 -12
  45. package/dist/components/spacer.d.ts.map +0 -1
  46. package/dist/components/spacer.js +0 -22
  47. package/dist/components/spacer.js.map +0 -1
  48. package/dist/components/text.d.ts +0 -19
  49. package/dist/components/text.d.ts.map +0 -1
  50. package/dist/components/text.js +0 -81
  51. package/dist/components/text.js.map +0 -1
  52. package/dist/components/truncated-text.d.ts +0 -13
  53. package/dist/components/truncated-text.d.ts.map +0 -1
  54. package/dist/components/truncated-text.js +0 -48
  55. package/dist/components/truncated-text.js.map +0 -1
  56. package/dist/editor-component.d.ts +0 -39
  57. package/dist/editor-component.d.ts.map +0 -1
  58. package/dist/editor-component.js +0 -2
  59. package/dist/editor-component.js.map +0 -1
  60. package/dist/fuzzy.d.ts +0 -16
  61. package/dist/fuzzy.d.ts.map +0 -1
  62. package/dist/fuzzy.js +0 -107
  63. package/dist/fuzzy.js.map +0 -1
  64. package/dist/index.d.ts +0 -23
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/index.js.map +0 -1
  67. package/dist/keybindings.d.ts +0 -39
  68. package/dist/keybindings.d.ts.map +0 -1
  69. package/dist/keybindings.js +0 -113
  70. package/dist/keybindings.js.map +0 -1
  71. package/dist/keys.d.ts +0 -175
  72. package/dist/keys.d.ts.map +0 -1
  73. package/dist/keys.js +0 -1015
  74. package/dist/keys.js.map +0 -1
  75. package/dist/kill-ring.d.ts +0 -28
  76. package/dist/kill-ring.d.ts.map +0 -1
  77. package/dist/kill-ring.js +0 -46
  78. package/dist/kill-ring.js.map +0 -1
  79. package/dist/stdin-buffer.d.ts +0 -48
  80. package/dist/stdin-buffer.d.ts.map +0 -1
  81. package/dist/stdin-buffer.js +0 -316
  82. package/dist/stdin-buffer.js.map +0 -1
  83. package/dist/terminal-image.d.ts +0 -68
  84. package/dist/terminal-image.d.ts.map +0 -1
  85. package/dist/terminal-image.js +0 -288
  86. package/dist/terminal-image.js.map +0 -1
  87. package/dist/terminal.d.ts +0 -84
  88. package/dist/terminal.d.ts.map +0 -1
  89. package/dist/terminal.js +0 -267
  90. package/dist/terminal.js.map +0 -1
  91. package/dist/tui.d.ts +0 -211
  92. package/dist/tui.d.ts.map +0 -1
  93. package/dist/tui.js +0 -961
  94. package/dist/tui.js.map +0 -1
  95. package/dist/undo-stack.d.ts +0 -17
  96. package/dist/undo-stack.d.ts.map +0 -1
  97. package/dist/undo-stack.js +0 -27
  98. package/dist/undo-stack.js.map +0 -1
  99. package/dist/utils.d.ts +0 -78
  100. package/dist/utils.d.ts.map +0 -1
  101. package/dist/utils.js +0 -817
  102. package/dist/utils.js.map +0 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @mariozechner/pi-tui
1
+ # @earendil-works/pi-tui
2
2
 
3
3
  Minimal terminal UI framework with differential rendering and synchronized output for flicker-free interactive CLI applications.
4
4
 
@@ -16,7 +16,7 @@ Minimal terminal UI framework with differential rendering and synchronized outpu
16
16
  ## Quick Start
17
17
 
18
18
  ```typescript
19
- import { TUI, Text, Editor, ProcessTerminal } from "@mariozechner/pi-tui";
19
+ import { TUI, Text, Editor, ProcessTerminal, matchesKey } from "@earendil-works/pi-tui";
20
20
 
21
21
  // Create terminal
22
22
  const terminal = new ProcessTerminal();
@@ -27,6 +27,7 @@ const tui = new TUI(terminal);
27
27
  // Add components
28
28
  tui.addChild(new Text("Welcome to my app!"));
29
29
 
30
+ import { defaultEditorTheme as editorTheme } from './test/test-themes.ts';
30
31
  const editor = new Editor(tui, editorTheme);
31
32
  editor.onSubmit = (text) => {
32
33
  console.log("Submitted:", text);
@@ -34,6 +35,17 @@ editor.onSubmit = (text) => {
34
35
  };
35
36
  tui.addChild(editor);
36
37
 
38
+ // Focus the editor so it receives keyboard input
39
+ tui.setFocus(editor);
40
+
41
+ // In raw mode Ctrl+C doesn't send SIGINT — intercept it here to allow exit
42
+ tui.addInputListener((data) => {
43
+ if (matchesKey(data, 'ctrl+c')) {
44
+ tui.stop();
45
+ process.exit(0);
46
+ }
47
+ });
48
+
37
49
  // Start
38
50
  tui.start();
39
51
  ```
@@ -93,6 +105,9 @@ const handle = tui.showOverlay(component, {
93
105
 
94
106
  // Responsive visibility
95
107
  visible: (termWidth, termHeight) => termWidth >= 100 // Hide on narrow terminals
108
+
109
+ // Focus behavior
110
+ nonCapturing: true // Don't auto-focus when shown
96
111
  });
97
112
 
98
113
  // OverlayHandle methods
@@ -100,6 +115,9 @@ handle.hide(); // Permanently remove the overlay
100
115
  handle.setHidden(true); // Temporarily hide (can show again)
101
116
  handle.setHidden(false); // Show again after hiding
102
117
  handle.isHidden(); // Check if temporarily hidden
118
+ handle.focus(); // Focus and bring to visual front
119
+ handle.unfocus(); // Release focus to previous target
120
+ handle.isFocused(); // Check if overlay has focus
103
121
 
104
122
  // Hide topmost overlay
105
123
  tui.hideOverlay();
@@ -141,7 +159,7 @@ The TUI appends a full SGR reset and OSC 8 reset at the end of each rendered lin
141
159
  Components that display a text cursor and need IME (Input Method Editor) support should implement the `Focusable` interface:
142
160
 
143
161
  ```typescript
144
- import { CURSOR_MARKER, type Component, type Focusable } from "@mariozechner/pi-tui";
162
+ import { CURSOR_MARKER, type Component, type Focusable } from "@earendil-works/pi-tui";
145
163
 
146
164
  class MyInput implements Component, Focusable {
147
165
  focused: boolean = false; // Set by TUI when focus changes
@@ -165,7 +183,7 @@ This enables IME candidate windows to appear at the correct position for CJK inp
165
183
  **Container components with embedded inputs:** When a container component (dialog, selector, etc.) contains an `Input` or `Editor` child, the container must implement `Focusable` and propagate the focus state to the child:
166
184
 
167
185
  ```typescript
168
- import { Container, type Focusable, Input } from "@mariozechner/pi-tui";
186
+ import { Container, type Focusable, Input } from "@earendil-works/pi-tui";
169
187
 
170
188
  class SearchDialog extends Container implements Focusable {
171
189
  private searchInput: Input;
@@ -512,7 +530,7 @@ Supported formats: PNG, JPEG, GIF, WebP. Dimensions are parsed from the image he
512
530
  Supports both slash commands and file paths.
513
531
 
514
532
  ```typescript
515
- import { CombinedAutocompleteProvider } from "@mariozechner/pi-tui";
533
+ import { CombinedAutocompleteProvider } from "@earendil-works/pi-tui";
516
534
 
517
535
  const provider = new CombinedAutocompleteProvider(
518
536
  [
@@ -537,7 +555,7 @@ editor.setAutocompleteProvider(provider);
537
555
  Use `matchesKey()` with the `Key` helper for detecting keyboard input (supports Kitty keyboard protocol):
538
556
 
539
557
  ```typescript
540
- import { matchesKey, Key } from "@mariozechner/pi-tui";
558
+ import { matchesKey, Key } from "@earendil-works/pi-tui";
541
559
 
542
560
  if (matchesKey(data, Key.ctrl("c"))) {
543
561
  process.exit(0);
@@ -595,7 +613,7 @@ interface Terminal {
595
613
  ## Utilities
596
614
 
597
615
  ```typescript
598
- import { visibleWidth, truncateToWidth, wrapTextWithAnsi } from "@mariozechner/pi-tui";
616
+ import { visibleWidth, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
599
617
 
600
618
  // Get visible width of string (ignoring ANSI codes)
601
619
  const width = visibleWidth("\x1b[31mHello\x1b[0m"); // 5
@@ -620,8 +638,8 @@ When creating custom components, **each line returned by `render()` must not exc
620
638
  Use `matchesKey()` with the `Key` helper for keyboard input:
621
639
 
622
640
  ```typescript
623
- import { matchesKey, Key, truncateToWidth } from "@mariozechner/pi-tui";
624
- import type { Component } from "@mariozechner/pi-tui";
641
+ import { matchesKey, Key, truncateToWidth } from "@earendil-works/pi-tui";
642
+ import type { Component } from "@earendil-works/pi-tui";
625
643
 
626
644
  class MyInteractiveComponent implements Component {
627
645
  private selectedIndex = 0;
@@ -656,8 +674,8 @@ class MyInteractiveComponent implements Component {
656
674
  Use the provided utilities to ensure lines fit:
657
675
 
658
676
  ```typescript
659
- import { visibleWidth, truncateToWidth } from "@mariozechner/pi-tui";
660
- import type { Component } from "@mariozechner/pi-tui";
677
+ import { visibleWidth, truncateToWidth } from "@earendil-works/pi-tui";
678
+ import type { Component } from "@earendil-works/pi-tui";
661
679
 
662
680
  class MyComponent implements Component {
663
681
  private text: string;
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { Image } from "./components/image.js";
9
9
  export { Input } from "./components/input.js";
10
10
  export { Loader } from "./components/loader.js";
11
11
  export { Markdown } from "./components/markdown.js";
12
- export { SelectList } from "./components/select-list.js";
12
+ export { SelectList, } from "./components/select-list.js";
13
13
  export { SettingsList } from "./components/settings-list.js";
14
14
  export { Spacer } from "./components/spacer.js";
15
15
  export { Text } from "./components/text.js";
@@ -17,7 +17,7 @@ export { TruncatedText } from "./components/truncated-text.js";
17
17
  // Fuzzy matching
18
18
  export { fuzzyFilter, fuzzyMatch } from "./fuzzy.js";
19
19
  // Keybindings
20
- export { DEFAULT_EDITOR_KEYBINDINGS, EditorKeybindingsManager, getEditorKeybindings, setEditorKeybindings, } from "./keybindings.js";
20
+ export { getKeybindings, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.js";
21
21
  // Keyboard input handling
22
22
  export { decodeKittyPrintable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, Key, matchesKey, parseKey, setKittyProtocolActive, } from "./keys.js";
23
23
  // Input buffering for batch splitting
@@ -25,7 +25,7 @@ export { StdinBuffer } from "./stdin-buffer.js";
25
25
  // Terminal interface and implementations
26
26
  export { ProcessTerminal } from "./terminal.js";
27
27
  // Terminal image support
28
- export { allocateImageId, calculateImageRows, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getPngDimensions, getWebpDimensions, imageFallback, renderImage, resetCapabilitiesCache, setCellDimensions, } from "./terminal-image.js";
28
+ export { allocateImageId, calculateImageRows, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getPngDimensions, getWebpDimensions, hyperlink, imageFallback, renderImage, resetCapabilitiesCache, setCapabilities, setCellDimensions, } from "./terminal-image.js";
29
29
  export { Container, CURSOR_MARKER, isFocusable, TUI, } from "./tui.js";
30
30
  // Utilities
31
31
  export { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "./utils.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phi-code-tui",
3
- "version": "0.56.3",
3
+ "version": "0.74.0",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "repository": {
30
30
  "type": "git",
31
- "url": "git+https://github.com/badlogic/pi-mono.git",
31
+ "url": "git+https://github.com/earendil-works/pi-mono.git",
32
32
  "directory": "packages/tui"
33
33
  },
34
34
  "engines": {
@@ -1,50 +0,0 @@
1
- export interface AutocompleteItem {
2
- value: string;
3
- label: string;
4
- description?: string;
5
- }
6
- export interface SlashCommand {
7
- name: string;
8
- description?: string;
9
- getArgumentCompletions?(argumentPrefix: string): AutocompleteItem[] | null;
10
- }
11
- export interface AutocompleteProvider {
12
- getSuggestions(lines: string[], cursorLine: number, cursorCol: number): {
13
- items: AutocompleteItem[];
14
- prefix: string;
15
- } | null;
16
- applyCompletion(lines: string[], cursorLine: number, cursorCol: number, item: AutocompleteItem, prefix: string): {
17
- lines: string[];
18
- cursorLine: number;
19
- cursorCol: number;
20
- };
21
- }
22
- export declare class CombinedAutocompleteProvider implements AutocompleteProvider {
23
- private commands;
24
- private basePath;
25
- private fdPath;
26
- constructor(commands?: (SlashCommand | AutocompleteItem)[], basePath?: string, fdPath?: string | null);
27
- getSuggestions(lines: string[], cursorLine: number, cursorCol: number): {
28
- items: AutocompleteItem[];
29
- prefix: string;
30
- } | null;
31
- applyCompletion(lines: string[], cursorLine: number, cursorCol: number, item: AutocompleteItem, prefix: string): {
32
- lines: string[];
33
- cursorLine: number;
34
- cursorCol: number;
35
- };
36
- private extractAtPrefix;
37
- private extractPathPrefix;
38
- private expandHomePath;
39
- private resolveScopedFuzzyQuery;
40
- private scopedPathForDisplay;
41
- private getFileSuggestions;
42
- private scoreEntry;
43
- private getFuzzyFileSuggestions;
44
- getForceFileSuggestions(lines: string[], cursorLine: number, cursorCol: number): {
45
- items: AutocompleteItem[];
46
- prefix: string;
47
- } | null;
48
- shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean;
49
- }
50
- //# sourceMappingURL=autocomplete.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../src/autocomplete.ts"],"names":[],"mappings":"AAmJA,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,sBAAsB,CAAC,CAAC,cAAc,EAAE,MAAM,GAAG,gBAAgB,EAAE,GAAG,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,oBAAoB;IAGpC,cAAc,CACb,KAAK,EAAE,MAAM,EAAE,EACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GACf;QACF,KAAK,EAAE,gBAAgB,EAAE,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;KACf,GAAG,IAAI,CAAC;IAIT,eAAe,CACd,KAAK,EAAE,MAAM,EAAE,EACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,MAAM,GACZ;QACF,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KAClB,CAAC;CACF;AAGD,qBAAa,4BAA6B,YAAW,oBAAoB;IACxE,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,QAAQ,CAAS;IAC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