jeopi-tui 16.2.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +1861 -0
  2. package/README.md +705 -0
  3. package/dist/types/autocomplete.d.ts +99 -0
  4. package/dist/types/bracketed-paste.d.ts +51 -0
  5. package/dist/types/components/box.d.ts +31 -0
  6. package/dist/types/components/cancellable-loader.d.ts +21 -0
  7. package/dist/types/components/editor.d.ts +155 -0
  8. package/dist/types/components/image.d.ts +112 -0
  9. package/dist/types/components/input.d.ts +23 -0
  10. package/dist/types/components/loader.d.ts +20 -0
  11. package/dist/types/components/markdown.d.ts +64 -0
  12. package/dist/types/components/scroll-view.d.ts +62 -0
  13. package/dist/types/components/select-list.d.ts +68 -0
  14. package/dist/types/components/settings-list.d.ts +123 -0
  15. package/dist/types/components/spacer.d.ts +11 -0
  16. package/dist/types/components/tab-bar.d.ts +89 -0
  17. package/dist/types/components/text.d.ts +14 -0
  18. package/dist/types/components/truncated-text.d.ts +10 -0
  19. package/dist/types/deccara.d.ts +49 -0
  20. package/dist/types/desktop-notify.d.ts +51 -0
  21. package/dist/types/editor-component.d.ts +38 -0
  22. package/dist/types/fuzzy.d.ts +32 -0
  23. package/dist/types/index.d.ts +32 -0
  24. package/dist/types/keybindings.d.ts +191 -0
  25. package/dist/types/keys.d.ts +208 -0
  26. package/dist/types/kill-ring.d.ts +20 -0
  27. package/dist/types/kitty-graphics.d.ts +79 -0
  28. package/dist/types/latex-block.d.ts +7 -0
  29. package/dist/types/latex-to-unicode.d.ts +33 -0
  30. package/dist/types/loop-watchdog.d.ts +39 -0
  31. package/dist/types/mouse.d.ts +67 -0
  32. package/dist/types/stdin-buffer.d.ts +60 -0
  33. package/dist/types/symbols.d.ts +25 -0
  34. package/dist/types/terminal-capabilities.d.ts +284 -0
  35. package/dist/types/terminal.d.ts +107 -0
  36. package/dist/types/ttyid.d.ts +9 -0
  37. package/dist/types/tui.d.ts +423 -0
  38. package/dist/types/utils.d.ts +95 -0
  39. package/package.json +73 -0
  40. package/src/autocomplete.ts +1026 -0
  41. package/src/bracketed-paste.ts +123 -0
  42. package/src/components/box.ts +194 -0
  43. package/src/components/cancellable-loader.ts +40 -0
  44. package/src/components/editor.ts +3092 -0
  45. package/src/components/image.ts +444 -0
  46. package/src/components/input.ts +474 -0
  47. package/src/components/loader.ts +103 -0
  48. package/src/components/markdown.ts +2068 -0
  49. package/src/components/scroll-view.ts +227 -0
  50. package/src/components/select-list.ts +531 -0
  51. package/src/components/settings-list.ts +793 -0
  52. package/src/components/spacer.ts +32 -0
  53. package/src/components/tab-bar.ts +300 -0
  54. package/src/components/text.ts +122 -0
  55. package/src/components/truncated-text.ts +69 -0
  56. package/src/deccara.ts +314 -0
  57. package/src/desktop-notify.ts +186 -0
  58. package/src/editor-component.ts +74 -0
  59. package/src/fuzzy.ts +356 -0
  60. package/src/index.ts +51 -0
  61. package/src/keybindings.ts +337 -0
  62. package/src/keys.ts +561 -0
  63. package/src/kill-ring.ts +51 -0
  64. package/src/kitty-graphics.ts +171 -0
  65. package/src/latex-block.ts +461 -0
  66. package/src/latex-to-unicode.ts +1994 -0
  67. package/src/loop-watchdog.ts +106 -0
  68. package/src/mouse.ts +105 -0
  69. package/src/stdin-buffer.ts +669 -0
  70. package/src/symbols.ts +26 -0
  71. package/src/terminal-capabilities.ts +1152 -0
  72. package/src/terminal.ts +1463 -0
  73. package/src/ttyid.ts +84 -0
  74. package/src/tui.ts +3901 -0
  75. package/src/utils.ts +570 -0
package/src/ttyid.ts ADDED
@@ -0,0 +1,84 @@
1
+ import { CString, dlopen, FFIType } from "bun:ffi";
2
+ import * as fs from "node:fs";
3
+ import * as os from "node:os";
4
+
5
+ /** Resolve the TTY device path for stdin (fd 0) via POSIX `ttyname(3)`. */
6
+ export function getTtyPath(): string | null {
7
+ if (os.platform() === "linux") {
8
+ // Linux: /proc/self/fd/0 is a symlink to /dev/pts/N
9
+ try {
10
+ const ttyPath = fs.readlinkSync("/proc/self/fd/0");
11
+ if (ttyPath.startsWith("/dev/")) {
12
+ return ttyPath;
13
+ }
14
+ } catch {
15
+ return null;
16
+ }
17
+ } else if (os.platform() !== "win32") {
18
+ try {
19
+ const libName = os.platform() === "darwin" ? "libSystem.B.dylib" : "libc.so.6";
20
+ const lib = dlopen(libName, {
21
+ ttyname: { args: [FFIType.i32], returns: FFIType.ptr },
22
+ });
23
+ try {
24
+ const result = lib.symbols.ttyname(0);
25
+ return result ? new CString(result).toString() : null;
26
+ } finally {
27
+ lib.close();
28
+ }
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+ return null;
34
+ }
35
+ /**
36
+ * Get a stable identifier for the current terminal.
37
+ * Uses the TTY device path (e.g., /dev/pts/3), falling back to environment
38
+ * variables for terminal multiplexers or terminal emulators.
39
+ * Returns null if no terminal can be identified (e.g., piped input).
40
+ */
41
+ export function getTerminalId(): string | null {
42
+ // TTY device path — most reliable, unique per terminal tab
43
+ if (process.stdin.isTTY) {
44
+ try {
45
+ const ttyPath = getTtyPath();
46
+ if (ttyPath?.startsWith("/dev/")) {
47
+ return ttyPath.slice(5).replace(/\//g, "-"); // /dev/pts/3 -> pts-3
48
+ }
49
+ } catch {}
50
+ }
51
+
52
+ // Fallback to terminal-specific env vars
53
+ // Prefer inner multiplexers over host terminal emulators when stdin has no TTY path.
54
+ const zellijPane = process.env.ZELLIJ_PANE_ID;
55
+ if (zellijPane) {
56
+ // Session names are user-chosen (`zellij -s …`) and the id is used as a
57
+ // breadcrumb filename — normalize path separators like the TTY branch does.
58
+ const zellijSession = process.env.ZELLIJ_SESSION_NAME?.replace(/[\\/]/g, "-");
59
+ return zellijSession ? `zellij-${zellijSession}-${zellijPane}` : `zellij-${zellijPane}`;
60
+ }
61
+
62
+ const tmuxPane = process.env.TMUX_PANE;
63
+ if (tmuxPane) return `tmux-${tmuxPane}`;
64
+
65
+ const cmuxSurface = process.env.CMUX_SURFACE_ID;
66
+ if (cmuxSurface) return `cmux-${cmuxSurface}`;
67
+
68
+ // Kitty before WezTerm/others, matching terminal-capabilities.ts detection
69
+ // order. Inherited env makes either order wrong for some nesting; staying
70
+ // consistent with the capability detector keeps the two answers aligned.
71
+ const kittyId = process.env.KITTY_WINDOW_ID;
72
+ if (kittyId) return `kitty-${kittyId}`;
73
+
74
+ const weztermPane = process.env.WEZTERM_PANE;
75
+ if (weztermPane) return `wezterm-${weztermPane}`;
76
+
77
+ const terminalSessionId = process.env.TERM_SESSION_ID; // macOS Terminal.app
78
+ if (terminalSessionId) return `apple-${terminalSessionId}`;
79
+
80
+ const wtSession = process.env.WT_SESSION; // Windows Terminal
81
+ if (wtSession) return `wt-${wtSession}`;
82
+
83
+ return null;
84
+ }