@dungle-scrubs/tallow 0.8.21 → 0.8.23

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 (217) hide show
  1. package/dist/cli.js +35 -4
  2. package/dist/cli.js.map +1 -1
  3. package/dist/config.d.ts +1 -1
  4. package/dist/config.js +1 -1
  5. package/dist/interactive-mode-patch.d.ts +2 -0
  6. package/dist/interactive-mode-patch.d.ts.map +1 -1
  7. package/dist/interactive-mode-patch.js +82 -0
  8. package/dist/interactive-mode-patch.js.map +1 -1
  9. package/dist/sdk.d.ts +17 -0
  10. package/dist/sdk.d.ts.map +1 -1
  11. package/dist/sdk.js +68 -1
  12. package/dist/sdk.js.map +1 -1
  13. package/dist/workspace-transition-relay.d.ts +40 -7
  14. package/dist/workspace-transition-relay.d.ts.map +1 -1
  15. package/dist/workspace-transition-relay.js +81 -16
  16. package/dist/workspace-transition-relay.js.map +1 -1
  17. package/extensions/__integration__/background-task-widget-ownership.test.ts +216 -0
  18. package/extensions/__integration__/claude-hooks-compat.test.ts +156 -0
  19. package/extensions/__integration__/slash-command-bridge.test.ts +169 -23
  20. package/extensions/_shared/atomic-write.ts +1 -1
  21. package/extensions/_shared/bordered-box.ts +102 -0
  22. package/extensions/_shared/interop-events.ts +5 -0
  23. package/extensions/_shared/pid-registry.ts +1 -1
  24. package/extensions/agent-commands-tool/index.ts +4 -1
  25. package/extensions/background-task-tool/__tests__/lifecycle.test.ts +50 -25
  26. package/extensions/background-task-tool/index.ts +139 -221
  27. package/extensions/bash-tool-enhanced/index.ts +1 -75
  28. package/extensions/cd-tool/index.ts +2 -2
  29. package/extensions/context-fork/spawn.ts +4 -1
  30. package/extensions/health/index.ts +6 -6
  31. package/extensions/hooks/__tests__/claude-compat.test.ts +35 -0
  32. package/extensions/hooks/__tests__/subprocess-hardening.test.ts +73 -0
  33. package/extensions/hooks/index.ts +27 -4
  34. package/extensions/loop/__tests__/loop.test.ts +168 -4
  35. package/extensions/loop/extension.json +6 -5
  36. package/extensions/loop/index.ts +242 -31
  37. package/extensions/plan-mode-tool/__tests__/agent-end-execution.test.ts +373 -0
  38. package/extensions/plan-mode-tool/index.ts +103 -41
  39. package/extensions/prompt-suggestions/__tests__/editor-compatibility.test.ts +42 -0
  40. package/extensions/prompt-suggestions/index.ts +41 -6
  41. package/extensions/slash-command-bridge/__tests__/slash-command-bridge.test.ts +267 -671
  42. package/extensions/slash-command-bridge/extension.json +1 -1
  43. package/extensions/slash-command-bridge/index.ts +230 -116
  44. package/extensions/subagent-tool/index.ts +2 -2
  45. package/extensions/subagent-tool/process.ts +4 -5
  46. package/extensions/tasks/commands/register-tasks-extension.ts +41 -0
  47. package/extensions/teams-tool/__tests__/peer-messaging.test.ts +29 -24
  48. package/extensions/teams-tool/dashboard.ts +3 -5
  49. package/extensions/teams-tool/dispatch/auto-dispatch.ts +18 -1
  50. package/extensions/teams-tool/tools/teammate-tools.ts +9 -6
  51. package/extensions/wezterm-pane-control/__tests__/index.test.ts +88 -4
  52. package/extensions/wezterm-pane-control/index.ts +113 -8
  53. package/package.json +6 -4
  54. package/packages/tallow-tui/README.md +51 -0
  55. package/packages/tallow-tui/dist/autocomplete.d.ts +48 -0
  56. package/packages/tallow-tui/dist/autocomplete.d.ts.map +1 -0
  57. package/packages/tallow-tui/dist/autocomplete.js +564 -0
  58. package/packages/tallow-tui/dist/autocomplete.js.map +1 -0
  59. package/packages/tallow-tui/dist/border-styles.d.ts +32 -0
  60. package/packages/tallow-tui/dist/border-styles.d.ts.map +1 -0
  61. package/packages/tallow-tui/dist/border-styles.js +46 -0
  62. package/packages/tallow-tui/dist/border-styles.js.map +1 -0
  63. package/packages/tallow-tui/dist/components/bordered-box.d.ts +52 -0
  64. package/packages/tallow-tui/dist/components/bordered-box.d.ts.map +1 -0
  65. package/packages/tallow-tui/dist/components/bordered-box.js +89 -0
  66. package/packages/tallow-tui/dist/components/bordered-box.js.map +1 -0
  67. package/packages/tallow-tui/dist/components/box.d.ts +22 -0
  68. package/packages/tallow-tui/dist/components/box.d.ts.map +1 -0
  69. package/packages/tallow-tui/dist/components/box.js +104 -0
  70. package/packages/tallow-tui/dist/components/box.js.map +1 -0
  71. package/packages/tallow-tui/dist/components/cancellable-loader.d.ts +22 -0
  72. package/packages/tallow-tui/dist/components/cancellable-loader.d.ts.map +1 -0
  73. package/packages/tallow-tui/dist/components/cancellable-loader.js +35 -0
  74. package/packages/tallow-tui/dist/components/cancellable-loader.js.map +1 -0
  75. package/packages/tallow-tui/dist/components/editor.d.ts +240 -0
  76. package/packages/tallow-tui/dist/components/editor.d.ts.map +1 -0
  77. package/packages/tallow-tui/dist/components/editor.js +1766 -0
  78. package/packages/tallow-tui/dist/components/editor.js.map +1 -0
  79. package/packages/tallow-tui/dist/components/image.d.ts +126 -0
  80. package/packages/tallow-tui/dist/components/image.d.ts.map +1 -0
  81. package/packages/tallow-tui/dist/components/image.js +245 -0
  82. package/packages/tallow-tui/dist/components/image.js.map +1 -0
  83. package/packages/tallow-tui/dist/components/input.d.ts +37 -0
  84. package/packages/tallow-tui/dist/components/input.d.ts.map +1 -0
  85. package/packages/tallow-tui/dist/components/input.js +439 -0
  86. package/packages/tallow-tui/dist/components/input.js.map +1 -0
  87. package/packages/tallow-tui/dist/components/loader.d.ts +88 -0
  88. package/packages/tallow-tui/dist/components/loader.d.ts.map +1 -0
  89. package/packages/tallow-tui/dist/components/loader.js +146 -0
  90. package/packages/tallow-tui/dist/components/loader.js.map +1 -0
  91. package/packages/tallow-tui/dist/components/markdown.d.ts +95 -0
  92. package/packages/tallow-tui/dist/components/markdown.d.ts.map +1 -0
  93. package/packages/tallow-tui/dist/components/markdown.js +633 -0
  94. package/packages/tallow-tui/dist/components/markdown.js.map +1 -0
  95. package/packages/tallow-tui/dist/components/select-list.d.ts +32 -0
  96. package/packages/tallow-tui/dist/components/select-list.d.ts.map +1 -0
  97. package/packages/tallow-tui/dist/components/select-list.js +156 -0
  98. package/packages/tallow-tui/dist/components/select-list.js.map +1 -0
  99. package/packages/tallow-tui/dist/components/settings-list.d.ts +50 -0
  100. package/packages/tallow-tui/dist/components/settings-list.d.ts.map +1 -0
  101. package/packages/tallow-tui/dist/components/settings-list.js +189 -0
  102. package/packages/tallow-tui/dist/components/settings-list.js.map +1 -0
  103. package/packages/tallow-tui/dist/components/spacer.d.ts +12 -0
  104. package/packages/tallow-tui/dist/components/spacer.d.ts.map +1 -0
  105. package/packages/tallow-tui/dist/components/spacer.js +23 -0
  106. package/packages/tallow-tui/dist/components/spacer.js.map +1 -0
  107. package/packages/tallow-tui/dist/components/text.d.ts +19 -0
  108. package/packages/tallow-tui/dist/components/text.d.ts.map +1 -0
  109. package/packages/tallow-tui/dist/components/text.js +91 -0
  110. package/packages/tallow-tui/dist/components/text.js.map +1 -0
  111. package/packages/tallow-tui/dist/components/truncated-text.d.ts +13 -0
  112. package/packages/tallow-tui/dist/components/truncated-text.d.ts.map +1 -0
  113. package/packages/tallow-tui/dist/components/truncated-text.js +51 -0
  114. package/packages/tallow-tui/dist/components/truncated-text.js.map +1 -0
  115. package/packages/tallow-tui/dist/editor-component.d.ts +50 -0
  116. package/packages/tallow-tui/dist/editor-component.d.ts.map +1 -0
  117. package/packages/tallow-tui/dist/editor-component.js +2 -0
  118. package/packages/tallow-tui/dist/editor-component.js.map +1 -0
  119. package/packages/tallow-tui/dist/fuzzy.d.ts +16 -0
  120. package/packages/tallow-tui/dist/fuzzy.d.ts.map +1 -0
  121. package/packages/tallow-tui/dist/fuzzy.js +107 -0
  122. package/packages/tallow-tui/dist/fuzzy.js.map +1 -0
  123. package/packages/tallow-tui/dist/index.d.ts +25 -0
  124. package/packages/tallow-tui/dist/index.d.ts.map +1 -0
  125. package/packages/tallow-tui/dist/index.js +35 -0
  126. package/packages/tallow-tui/dist/index.js.map +1 -0
  127. package/packages/tallow-tui/dist/keybindings.d.ts +39 -0
  128. package/packages/tallow-tui/dist/keybindings.d.ts.map +1 -0
  129. package/packages/tallow-tui/dist/keybindings.js +114 -0
  130. package/packages/tallow-tui/dist/keybindings.js.map +1 -0
  131. package/packages/tallow-tui/dist/keys.d.ts +168 -0
  132. package/packages/tallow-tui/dist/keys.d.ts.map +1 -0
  133. package/packages/tallow-tui/dist/keys.js +971 -0
  134. package/packages/tallow-tui/dist/keys.js.map +1 -0
  135. package/packages/tallow-tui/dist/kill-ring.d.ts +28 -0
  136. package/packages/tallow-tui/dist/kill-ring.d.ts.map +1 -0
  137. package/packages/tallow-tui/dist/kill-ring.js +44 -0
  138. package/packages/tallow-tui/dist/kill-ring.js.map +1 -0
  139. package/packages/tallow-tui/dist/stdin-buffer.d.ts +48 -0
  140. package/packages/tallow-tui/dist/stdin-buffer.d.ts.map +1 -0
  141. package/packages/tallow-tui/dist/stdin-buffer.js +317 -0
  142. package/packages/tallow-tui/dist/stdin-buffer.js.map +1 -0
  143. package/packages/tallow-tui/dist/terminal-image.d.ts +161 -0
  144. package/packages/tallow-tui/dist/terminal-image.d.ts.map +1 -0
  145. package/packages/tallow-tui/dist/terminal-image.js +460 -0
  146. package/packages/tallow-tui/dist/terminal-image.js.map +1 -0
  147. package/packages/tallow-tui/dist/terminal.d.ts +102 -0
  148. package/packages/tallow-tui/dist/terminal.d.ts.map +1 -0
  149. package/packages/tallow-tui/dist/terminal.js +263 -0
  150. package/packages/tallow-tui/dist/terminal.js.map +1 -0
  151. package/packages/tallow-tui/dist/test-utils/capability-env.d.ts +14 -0
  152. package/packages/tallow-tui/dist/test-utils/capability-env.d.ts.map +1 -0
  153. package/packages/tallow-tui/dist/test-utils/capability-env.js +55 -0
  154. package/packages/tallow-tui/dist/test-utils/capability-env.js.map +1 -0
  155. package/packages/tallow-tui/dist/tui.d.ts +239 -0
  156. package/packages/tallow-tui/dist/tui.d.ts.map +1 -0
  157. package/packages/tallow-tui/dist/tui.js +1058 -0
  158. package/packages/tallow-tui/dist/tui.js.map +1 -0
  159. package/packages/tallow-tui/dist/undo-stack.d.ts +17 -0
  160. package/packages/tallow-tui/dist/undo-stack.d.ts.map +1 -0
  161. package/packages/tallow-tui/dist/undo-stack.js +25 -0
  162. package/packages/tallow-tui/dist/undo-stack.js.map +1 -0
  163. package/packages/tallow-tui/dist/utils.d.ts +96 -0
  164. package/packages/tallow-tui/dist/utils.d.ts.map +1 -0
  165. package/packages/tallow-tui/dist/utils.js +843 -0
  166. package/packages/tallow-tui/dist/utils.js.map +1 -0
  167. package/packages/tallow-tui/package.json +24 -0
  168. package/packages/tallow-tui/src/__tests__/__snapshots__/render.test.ts.snap +121 -0
  169. package/packages/tallow-tui/src/__tests__/editor-border.test.ts +72 -0
  170. package/packages/tallow-tui/src/__tests__/editor-change-listener.test.ts +121 -0
  171. package/packages/tallow-tui/src/__tests__/editor-ghost-text.test.ts +112 -0
  172. package/packages/tallow-tui/src/__tests__/fuzzy.test.ts +91 -0
  173. package/packages/tallow-tui/src/__tests__/image-component.test.ts +113 -0
  174. package/packages/tallow-tui/src/__tests__/keys.test.ts +141 -0
  175. package/packages/tallow-tui/src/__tests__/render.test.ts +179 -0
  176. package/packages/tallow-tui/src/__tests__/stdin-buffer.test.ts +82 -0
  177. package/packages/tallow-tui/src/__tests__/terminal-image.test.ts +363 -0
  178. package/packages/tallow-tui/src/__tests__/tui-diff-regression.test.ts +454 -0
  179. package/packages/tallow-tui/src/__tests__/tui-render-scheduling.test.ts +256 -0
  180. package/packages/tallow-tui/src/__tests__/utils.test.ts +259 -0
  181. package/packages/tallow-tui/src/autocomplete.ts +716 -0
  182. package/packages/tallow-tui/src/border-styles.ts +60 -0
  183. package/packages/tallow-tui/src/components/bordered-box.ts +113 -0
  184. package/packages/tallow-tui/src/components/box.ts +137 -0
  185. package/packages/tallow-tui/src/components/cancellable-loader.ts +40 -0
  186. package/packages/tallow-tui/src/components/editor.ts +2143 -0
  187. package/packages/tallow-tui/src/components/image.ts +315 -0
  188. package/packages/tallow-tui/src/components/input.ts +522 -0
  189. package/packages/tallow-tui/src/components/loader.ts +187 -0
  190. package/packages/tallow-tui/src/components/markdown.ts +780 -0
  191. package/packages/tallow-tui/src/components/select-list.ts +197 -0
  192. package/packages/tallow-tui/src/components/settings-list.ts +264 -0
  193. package/packages/tallow-tui/src/components/spacer.ts +28 -0
  194. package/packages/tallow-tui/src/components/text.ts +113 -0
  195. package/packages/tallow-tui/src/components/truncated-text.ts +65 -0
  196. package/packages/tallow-tui/src/editor-component.ts +92 -0
  197. package/packages/tallow-tui/src/fuzzy.ts +133 -0
  198. package/packages/tallow-tui/src/index.ts +118 -0
  199. package/packages/tallow-tui/src/keybindings.ts +183 -0
  200. package/packages/tallow-tui/src/keys.ts +1189 -0
  201. package/packages/tallow-tui/src/kill-ring.ts +46 -0
  202. package/packages/tallow-tui/src/stdin-buffer.ts +386 -0
  203. package/packages/tallow-tui/src/terminal-image.ts +619 -0
  204. package/packages/tallow-tui/src/terminal.ts +350 -0
  205. package/packages/tallow-tui/src/test-utils/capability-env.ts +56 -0
  206. package/packages/tallow-tui/src/tui.ts +1336 -0
  207. package/packages/tallow-tui/src/undo-stack.ts +28 -0
  208. package/packages/tallow-tui/src/utils.ts +948 -0
  209. package/packages/tallow-tui/tsconfig.build.json +21 -0
  210. package/runtime/agent-runner.ts +20 -0
  211. package/runtime/atomic-write.ts +8 -0
  212. package/runtime/otel.ts +12 -0
  213. package/runtime/resolve-module.ts +23 -0
  214. package/runtime/runtime-path-provider.ts +12 -0
  215. package/runtime/runtime-provenance.ts +17 -0
  216. package/runtime/workspace-transition-relay.ts +21 -0
  217. package/runtime/workspace-transition.ts +29 -0
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Border character sets for box-drawing.
3
+ *
4
+ * @module
5
+ */
6
+ /** Sharp corners — standard box-drawing (┌┐└┘). */
7
+ export const SHARP = {
8
+ topLeft: "┌",
9
+ topRight: "┐",
10
+ bottomLeft: "└",
11
+ bottomRight: "┘",
12
+ horizontal: "─",
13
+ vertical: "│",
14
+ };
15
+ /** Rounded corners — Unicode arc box-drawing (╭╮╰╯). */
16
+ export const ROUNDED = {
17
+ topLeft: "╭",
18
+ topRight: "╮",
19
+ bottomLeft: "╰",
20
+ bottomRight: "╯",
21
+ horizontal: "─",
22
+ vertical: "│",
23
+ };
24
+ /** Flat — horizontal rules only, no corners or verticals. */
25
+ export const FLAT = {
26
+ topLeft: "─",
27
+ topRight: "─",
28
+ bottomLeft: "─",
29
+ bottomRight: "─",
30
+ horizontal: "─",
31
+ vertical: " ",
32
+ };
33
+ /**
34
+ * Global default border style — set once, applies to all new BorderedBox instances.
35
+ * Extensions can set this at session_start to override.
36
+ */
37
+ export let defaultBorderStyle = SHARP;
38
+ /**
39
+ * Set the global default border style.
40
+ *
41
+ * @param style - Border style to use as default
42
+ */
43
+ export function setDefaultBorderStyle(style) {
44
+ defaultBorderStyle = style;
45
+ }
46
+ //# sourceMappingURL=border-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"border-styles.js","sourceRoot":"","sources":["../src/border-styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,mDAAmD;AACnD,MAAM,CAAC,MAAM,KAAK,GAAgB;IACjC,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,GAAG;CACb,CAAC;AAEF,wDAAwD;AACxD,MAAM,CAAC,MAAM,OAAO,GAAgB;IACnC,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,GAAG;CACb,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,IAAI,GAAgB;IAChC,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,GAAG;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,IAAI,kBAAkB,GAAgB,KAAK,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAkB;IACvD,kBAAkB,GAAG,KAAK,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Box component with configurable border style (sharp, rounded, flat).
3
+ *
4
+ * Wraps child content lines in a full border with optional title,
5
+ * padding, and background fill.
6
+ *
7
+ * @module
8
+ */
9
+ import { type BorderStyle } from "../border-styles.js";
10
+ import { Text } from "./text.js";
11
+ /** Configuration for a BorderedBox. */
12
+ export interface BorderedBoxOptions {
13
+ /** Border character set (defaults to global defaultBorderStyle). */
14
+ borderStyle?: BorderStyle;
15
+ /** Title rendered in the top border (optional). */
16
+ title?: string;
17
+ /** Horizontal padding inside the border (default: 1). */
18
+ paddingX?: number;
19
+ /** Color function applied to border characters. */
20
+ borderColorFn?: (str: string) => string;
21
+ /** Color function applied to the title. */
22
+ titleColorFn?: (str: string) => string;
23
+ }
24
+ /**
25
+ * Renders content inside a bordered box.
26
+ *
27
+ * Usage:
28
+ * ```typescript
29
+ * const box = new BorderedBox(["line 1", "line 2"], {
30
+ * borderStyle: ROUNDED,
31
+ * title: "Output",
32
+ * });
33
+ * const lines = box.render(80);
34
+ * ```
35
+ */
36
+ export declare class BorderedBox extends Text {
37
+ private contentLines;
38
+ private options;
39
+ /**
40
+ * @param contentLines - Pre-rendered content lines to wrap
41
+ * @param options - Border style, title, padding, color functions
42
+ */
43
+ constructor(contentLines: string[], options?: BorderedBoxOptions);
44
+ /**
45
+ * Render the bordered box to an array of terminal lines.
46
+ *
47
+ * @param width - Available terminal width
48
+ * @returns Array of rendered lines including top/bottom borders
49
+ */
50
+ render(width: number): string[];
51
+ }
52
+ //# sourceMappingURL=bordered-box.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bordered-box.d.ts","sourceRoot":"","sources":["../../src/components/bordered-box.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IAClC,oEAAoE;IACpE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,WAAY,SAAQ,IAAI;IACpC,OAAO,CAAC,YAAY,CAAW;IAC/B,OAAO,CAAC,OAAO,CAAqB;IAEpC;;;OAGG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,kBAAuB;IAMpE;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAqD/B"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Box component with configurable border style (sharp, rounded, flat).
3
+ *
4
+ * Wraps child content lines in a full border with optional title,
5
+ * padding, and background fill.
6
+ *
7
+ * @module
8
+ */
9
+ import { defaultBorderStyle } from "../border-styles.js";
10
+ import { truncateToWidth, visibleWidth } from "../utils.js";
11
+ import { Text } from "./text.js";
12
+ /**
13
+ * Renders content inside a bordered box.
14
+ *
15
+ * Usage:
16
+ * ```typescript
17
+ * const box = new BorderedBox(["line 1", "line 2"], {
18
+ * borderStyle: ROUNDED,
19
+ * title: "Output",
20
+ * });
21
+ * const lines = box.render(80);
22
+ * ```
23
+ */
24
+ export class BorderedBox extends Text {
25
+ contentLines;
26
+ options;
27
+ /**
28
+ * @param contentLines - Pre-rendered content lines to wrap
29
+ * @param options - Border style, title, padding, color functions
30
+ */
31
+ constructor(contentLines, options = {}) {
32
+ super("", contentLines.length + 2, 0);
33
+ this.contentLines = contentLines;
34
+ this.options = options;
35
+ }
36
+ /**
37
+ * Render the bordered box to an array of terminal lines.
38
+ *
39
+ * @param width - Available terminal width
40
+ * @returns Array of rendered lines including top/bottom borders
41
+ */
42
+ render(width) {
43
+ const style = this.options.borderStyle ?? defaultBorderStyle;
44
+ const padX = this.options.paddingX ?? 1;
45
+ const colorBorder = this.options.borderColorFn ?? ((s) => s);
46
+ const colorTitle = this.options.titleColorFn ?? ((s) => s);
47
+ const innerWidth = width - 2 - padX * 2; // borders + padding
48
+ if (innerWidth < 1)
49
+ return this.contentLines;
50
+ const pad = " ".repeat(padX);
51
+ // Top border with optional title
52
+ let topBar;
53
+ if (this.options.title) {
54
+ const titleStr = ` ${colorTitle(this.options.title)} `;
55
+ const titleVisLen = visibleWidth(titleStr);
56
+ // topLeft(1) + leftBar(1) + titleStr + rightBar(rightFill) + topRight(1)
57
+ const rightFill = Math.max(0, width - 3 - titleVisLen);
58
+ topBar =
59
+ colorBorder(style.topLeft) +
60
+ colorBorder(style.horizontal) +
61
+ titleStr +
62
+ colorBorder(style.horizontal.repeat(rightFill)) +
63
+ colorBorder(style.topRight);
64
+ }
65
+ else {
66
+ topBar =
67
+ colorBorder(style.topLeft) +
68
+ colorBorder(style.horizontal.repeat(width - 2)) +
69
+ colorBorder(style.topRight);
70
+ }
71
+ // Content lines with side borders
72
+ const bodyLines = this.contentLines.map((line) => {
73
+ const clamped = visibleWidth(line) > innerWidth ? truncateToWidth(line, innerWidth) : line;
74
+ const fill = Math.max(0, innerWidth - visibleWidth(clamped));
75
+ return (colorBorder(style.vertical) +
76
+ pad +
77
+ clamped +
78
+ " ".repeat(fill) +
79
+ pad +
80
+ colorBorder(style.vertical));
81
+ });
82
+ // Bottom border
83
+ const bottomBar = colorBorder(style.bottomLeft) +
84
+ colorBorder(style.horizontal.repeat(width - 2)) +
85
+ colorBorder(style.bottomRight);
86
+ return [topBar, ...bodyLines, bottomBar];
87
+ }
88
+ }
89
+ //# sourceMappingURL=bordered-box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bordered-box.js","sourceRoot":"","sources":["../../src/components/bordered-box.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAoB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAgBjC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,WAAY,SAAQ,IAAI;IAC5B,YAAY,CAAW;IACvB,OAAO,CAAqB;IAEpC;;;OAGG;IACH,YAAY,YAAsB,EAAE,UAA8B,EAAE;QACnE,KAAK,CAAC,EAAE,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAa;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,kBAAkB,CAAC;QAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAEnE,MAAM,UAAU,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAC7D,IAAI,U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CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;YAC7D,OAAO,CACN,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAC3B,GAAG;gBACH,OAAO;gBACP,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;gBAChB,GAAG;gBACH,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC3B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,gBAAgB;QAChB,MAAM,SAAS,GACd,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC;YAC7B,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAC/C,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAEhC,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;CACD"}
@@ -0,0 +1,22 @@
1
+ import type { Component } from "../tui.js";
2
+ /**
3
+ * Box component - a container that applies padding and background to all children
4
+ */
5
+ export declare class Box implements Component {
6
+ children: Component[];
7
+ private paddingX;
8
+ private paddingY;
9
+ private bgFn?;
10
+ private cache?;
11
+ constructor(paddingX?: number, paddingY?: number, bgFn?: (text: string) => string);
12
+ addChild(component: Component): void;
13
+ removeChild(component: Component): void;
14
+ clear(): void;
15
+ setBgFn(bgFn?: (text: string) => string): void;
16
+ private invalidateCache;
17
+ private matchCache;
18
+ invalidate(): void;
19
+ render(width: number): string[];
20
+ private applyBg;
21
+ }
22
+ //# sourceMappingURL=box.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/components/box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAU3C;;GAEG;AACH,qBAAa,GAAI,YAAW,SAAS;IACpC,QAAQ,EAAE,SAAS,EAAE,CAAM;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAAC,CAA2B;IAGxC,OAAO,CAAC,KAAK,CAAC,CAAc;gBAEhB,QAAQ,SAAI,EAAE,QAAQ,SAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM;IAMvE,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAKpC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAQvC,KAAK,IAAI,IAAI;IAKb,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI;IAK9C,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,UAAU;IAWlB,UAAU,IAAI,IAAI;IAOlB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAqD/B,OAAO,CAAC,OAAO;CAUf"}
@@ -0,0 +1,104 @@
1
+ import { applyBackgroundToLine, visibleWidth } from "../utils.js";
2
+ /**
3
+ * Box component - a container that applies padding and background to all children
4
+ */
5
+ export class Box {
6
+ children = [];
7
+ paddingX;
8
+ paddingY;
9
+ bgFn;
10
+ // Cache for rendered output
11
+ cache;
12
+ constructor(paddingX = 1, paddingY = 1, bgFn) {
13
+ this.paddingX = paddingX;
14
+ this.paddingY = paddingY;
15
+ this.bgFn = bgFn;
16
+ }
17
+ addChild(component) {
18
+ this.children.push(component);
19
+ this.invalidateCache();
20
+ }
21
+ removeChild(component) {
22
+ const index = this.children.indexOf(component);
23
+ if (index !== -1) {
24
+ this.children.splice(index, 1);
25
+ this.invalidateCache();
26
+ }
27
+ }
28
+ clear() {
29
+ this.children = [];
30
+ this.invalidateCache();
31
+ }
32
+ setBgFn(bgFn) {
33
+ this.bgFn = bgFn;
34
+ // Don't invalidate here - we'll detect bgFn changes by sampling output
35
+ }
36
+ invalidateCache() {
37
+ this.cache = undefined;
38
+ }
39
+ matchCache(width, childLines, bgSample) {
40
+ const cache = this.cache;
41
+ return (!!cache &&
42
+ cache.width === width &&
43
+ cache.bgSample === bgSample &&
44
+ cache.childLines.length === childLines.length &&
45
+ cache.childLines.every((line, i) => line === childLines[i]));
46
+ }
47
+ invalidate() {
48
+ this.invalidateCache();
49
+ for (const child of this.children) {
50
+ child.invalidate?.();
51
+ }
52
+ }
53
+ render(width) {
54
+ if (this.children.length === 0) {
55
+ return [];
56
+ }
57
+ const contentWidth = Math.max(1, width - this.paddingX * 2);
58
+ const leftPad = " ".repeat(this.paddingX);
59
+ // Render all children
60
+ const childLines = [];
61
+ for (const child of this.children) {
62
+ const lines = child.render(contentWidth);
63
+ for (const line of lines) {
64
+ childLines.push(leftPad + line);
65
+ }
66
+ }
67
+ if (childLines.length === 0) {
68
+ return [];
69
+ }
70
+ // Check if bgFn output changed by sampling
71
+ const bgSample = this.bgFn ? this.bgFn("test") : undefined;
72
+ // Check cache validity
73
+ if (this.matchCache(width, childLines, bgSample)) {
74
+ return this.cache.lines;
75
+ }
76
+ // Apply background and padding
77
+ const result = [];
78
+ // Top padding
79
+ for (let i = 0; i < this.paddingY; i++) {
80
+ result.push(this.applyBg("", width));
81
+ }
82
+ // Content
83
+ for (const line of childLines) {
84
+ result.push(this.applyBg(line, width));
85
+ }
86
+ // Bottom padding
87
+ for (let i = 0; i < this.paddingY; i++) {
88
+ result.push(this.applyBg("", width));
89
+ }
90
+ // Update cache
91
+ this.cache = { childLines, width, bgSample, lines: result };
92
+ return result;
93
+ }
94
+ applyBg(line, width) {
95
+ const visLen = visibleWidth(line);
96
+ const padNeeded = Math.max(0, width - visLen);
97
+ const padded = line + " ".repeat(padNeeded);
98
+ if (this.bgFn) {
99
+ return applyBackgroundToLine(padded, width, this.bgFn);
100
+ }
101
+ return padded;
102
+ }
103
+ }
104
+ //# sourceMappingURL=box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box.js","sourceRoot":"","sources":["../../src/components/box.ts"],"names":[],"mappings":"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G,MAAM,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE5C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;CACD"}
@@ -0,0 +1,22 @@
1
+ import { Loader } from "./loader.js";
2
+ /**
3
+ * Loader that can be cancelled with Escape.
4
+ * Extends Loader with an AbortSignal for cancelling async operations.
5
+ *
6
+ * @example
7
+ * const loader = new CancellableLoader(tui, cyan, dim, "Working...");
8
+ * loader.onAbort = () => done(null);
9
+ * doWork(loader.signal).then(done);
10
+ */
11
+ export declare class CancellableLoader extends Loader {
12
+ private abortController;
13
+ /** Called when user presses Escape */
14
+ onAbort?: () => void;
15
+ /** AbortSignal that is aborted when user presses Escape */
16
+ get signal(): AbortSignal;
17
+ /** Whether the loader was aborted */
18
+ get aborted(): boolean;
19
+ handleInput(data: string): void;
20
+ dispose(): void;
21
+ }
22
+ //# sourceMappingURL=cancellable-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancellable-loader.d.ts","sourceRoot":"","sources":["../../src/components/cancellable-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,SAAQ,MAAM;IAC5C,OAAO,CAAC,eAAe,CAAyB;IAEhD,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,2DAA2D;IAC3D,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,qCAAqC;IACrC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQ/B,OAAO,IAAI,IAAI;CAGf"}
@@ -0,0 +1,35 @@
1
+ import { getEditorKeybindings } from "../keybindings.js";
2
+ import { Loader } from "./loader.js";
3
+ /**
4
+ * Loader that can be cancelled with Escape.
5
+ * Extends Loader with an AbortSignal for cancelling async operations.
6
+ *
7
+ * @example
8
+ * const loader = new CancellableLoader(tui, cyan, dim, "Working...");
9
+ * loader.onAbort = () => done(null);
10
+ * doWork(loader.signal).then(done);
11
+ */
12
+ export class CancellableLoader extends Loader {
13
+ abortController = new AbortController();
14
+ /** Called when user presses Escape */
15
+ onAbort;
16
+ /** AbortSignal that is aborted when user presses Escape */
17
+ get signal() {
18
+ return this.abortController.signal;
19
+ }
20
+ /** Whether the loader was aborted */
21
+ get aborted() {
22
+ return this.abortController.signal.aborted;
23
+ }
24
+ handleInput(data) {
25
+ const kb = getEditorKeybindings();
26
+ if (kb.matches(data, "selectCancel")) {
27
+ this.abortController.abort();
28
+ this.onAbort?.();
29
+ }
30
+ }
31
+ dispose() {
32
+ this.stop();
33
+ }
34
+ }
35
+ //# sourceMappingURL=cancellable-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancellable-loader.js","sourceRoot":"","sources":["../../src/components/cancellable-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,MAAM;IACpC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAEhD,sCAAsC;IACtC,OAAO,CAAc;IAErB,2DAA2D;IAC3D,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;IACpC,CAAC;IAED,qCAAqC;IACrC,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC;IAC5C,CAAC;IAED,WAAW,CAAC,IAAY;QACvB,MAAM,EAAE,GAAG,oBAAoB,EAAE,CAAC;QAClC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QAClB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;CACD"}
@@ -0,0 +1,240 @@
1
+ import type { AutocompleteProvider } from "../autocomplete.js";
2
+ import { type Component, type Focusable, type TUI } from "../tui.js";
3
+ import { type SelectListTheme } from "./select-list.js";
4
+ /**
5
+ * Represents a chunk of text for word-wrap layout.
6
+ * Tracks both the text content and its position in the original line.
7
+ */
8
+ export interface TextChunk {
9
+ text: string;
10
+ startIndex: number;
11
+ endIndex: number;
12
+ }
13
+ /**
14
+ * Split a line into word-wrapped chunks.
15
+ * Wraps at word boundaries when possible, falling back to character-level
16
+ * wrapping for words longer than the available width.
17
+ *
18
+ * @param line - The text line to wrap
19
+ * @param maxWidth - Maximum visible width per chunk
20
+ * @returns Array of chunks with text and position information
21
+ */
22
+ export declare function wordWrapLine(line: string, maxWidth: number): TextChunk[];
23
+ export interface EditorTheme {
24
+ borderColor: (str: string) => string;
25
+ selectList: SelectListTheme;
26
+ }
27
+ export interface EditorOptions {
28
+ paddingX?: number;
29
+ autocompleteMaxVisible?: number;
30
+ }
31
+ export declare class Editor implements Component, Focusable {
32
+ private state;
33
+ /** Focusable interface - set by TUI when focus changes */
34
+ focused: boolean;
35
+ protected tui: TUI;
36
+ private theme;
37
+ private paddingX;
38
+ private lastWidth;
39
+ private scrollOffset;
40
+ borderColor: (str: string) => string;
41
+ private autocompleteProvider?;
42
+ private autocompleteList?;
43
+ private autocompleteState;
44
+ private autocompletePrefix;
45
+ private autocompleteMaxVisible;
46
+ private pastes;
47
+ private pasteCounter;
48
+ private pasteBuffer;
49
+ private isInPaste;
50
+ private history;
51
+ private historyIndex;
52
+ private killRing;
53
+ private lastAction;
54
+ private jumpMode;
55
+ private preferredVisualCol;
56
+ private undoStack;
57
+ private ghostTextValue;
58
+ /** Additional change listeners that won't be overwritten by framework wiring. */
59
+ private changeListeners;
60
+ onSubmit?: (text: string) => void;
61
+ onChange?: (text: string) => void;
62
+ disableSubmit: boolean;
63
+ constructor(tui: TUI, theme: EditorTheme, options?: EditorOptions);
64
+ getPaddingX(): number;
65
+ setPaddingX(padding: number): void;
66
+ getAutocompleteMaxVisible(): number;
67
+ setAutocompleteMaxVisible(maxVisible: number): void;
68
+ setAutocompleteProvider(provider: AutocompleteProvider): void;
69
+ /**
70
+ * Add a prompt to history for up/down arrow navigation.
71
+ * Called after successful submission.
72
+ */
73
+ addToHistory(text: string): void;
74
+ private isEditorEmpty;
75
+ private isOnFirstVisualLine;
76
+ private isOnLastVisualLine;
77
+ private navigateHistory;
78
+ /** Internal setText that doesn't reset history state - used by navigateHistory */
79
+ private setTextInternal;
80
+ invalidate(): void;
81
+ render(width: number): string[];
82
+ handleInput(data: string): void;
83
+ private layoutText;
84
+ getText(): string;
85
+ /**
86
+ * Get text with paste markers expanded to their actual content.
87
+ * Use this when you need the full content (e.g., for external editor).
88
+ */
89
+ getExpandedText(): string;
90
+ getLines(): string[];
91
+ getCursor(): {
92
+ line: number;
93
+ col: number;
94
+ };
95
+ setText(text: string): void;
96
+ /**
97
+ * Set ghost text (inline suggestion shown as dim text after the cursor).
98
+ * Pass null to clear. Ghost text is purely visual — not part of the buffer.
99
+ *
100
+ * @param text - Suggestion to display, or null to clear
101
+ */
102
+ setGhostText(text: string | null): void;
103
+ /**
104
+ * Get the current ghost text, or null if none.
105
+ *
106
+ * @returns Current ghost text string, or null
107
+ */
108
+ getGhostText(): string | null;
109
+ /**
110
+ * Register a change listener that fires alongside onChange.
111
+ * Unlike onChange, listeners aren't overwritten by framework wiring.
112
+ *
113
+ * @param fn - Callback receiving the new text content
114
+ */
115
+ addChangeListener(fn: (text: string) => void): void;
116
+ /**
117
+ * Notify onChange and all registered change listeners.
118
+ * Centralises all text-change notifications.
119
+ */
120
+ private notifyChange;
121
+ /**
122
+ * Accept ghost text into the editor buffer at the cursor position.
123
+ * Clears ghost text and triggers onChange.
124
+ *
125
+ * @returns true if ghost text was accepted, false if none was showing
126
+ */
127
+ private acceptGhostText;
128
+ /**
129
+ * Insert text at the current cursor position.
130
+ * Used for programmatic insertion (e.g., clipboard image markers).
131
+ * This is atomic for undo - single undo restores entire pre-insert state.
132
+ */
133
+ insertTextAtCursor(text: string): void;
134
+ /**
135
+ * Internal text insertion at cursor. Handles single and multi-line text.
136
+ * Does not push undo snapshots or trigger autocomplete - caller is responsible.
137
+ * Normalizes line endings and calls onChange once at the end.
138
+ */
139
+ private insertTextAtCursorInternal;
140
+ private insertCharacter;
141
+ private handlePaste;
142
+ private addNewLine;
143
+ private shouldSubmitOnBackslashEnter;
144
+ private submitValue;
145
+ private handleBackspace;
146
+ /**
147
+ * Set cursor column and clear preferredVisualCol.
148
+ * Use this for all non-vertical cursor movements to reset sticky column behavior.
149
+ */
150
+ private setCursorCol;
151
+ /**
152
+ * Move cursor to a target visual line, applying sticky column logic.
153
+ * Shared by moveCursor() and pageScroll().
154
+ */
155
+ private moveToVisualLine;
156
+ /**
157
+ * Compute the target visual column for vertical cursor movement.
158
+ * Implements the sticky column decision table:
159
+ *
160
+ * | P | S | T | U | Scenario | Set Preferred | Move To |
161
+ * |---|---|---|---| ---------------------------------------------------- |---------------|-------------|
162
+ * | 0 | * | 0 | - | Start nav, target fits | null | current |
163
+ * | 0 | * | 1 | - | Start nav, target shorter | current | target end |
164
+ * | 1 | 0 | 0 | 0 | Clamped, target fits preferred | null | preferred |
165
+ * | 1 | 0 | 0 | 1 | Clamped, target longer but still can't fit preferred | keep | target end |
166
+ * | 1 | 0 | 1 | - | Clamped, target even shorter | keep | target end |
167
+ * | 1 | 1 | 0 | - | Rewrapped, target fits current | null | current |
168
+ * | 1 | 1 | 1 | - | Rewrapped, target shorter than current | current | target end |
169
+ *
170
+ * Where:
171
+ * - P = preferred col is set
172
+ * - S = cursor in middle of source line (not clamped to end)
173
+ * - T = target line shorter than current visual col
174
+ * - U = target line shorter than preferred col
175
+ */
176
+ private computeVerticalMoveColumn;
177
+ private moveToLineStart;
178
+ private moveToLineEnd;
179
+ private deleteToStartOfLine;
180
+ private deleteToEndOfLine;
181
+ private deleteWordBackwards;
182
+ private deleteWordForward;
183
+ private handleForwardDelete;
184
+ /**
185
+ * Build a mapping from visual lines to logical positions.
186
+ * Returns an array where each element represents a visual line with:
187
+ * - logicalLine: index into this.state.lines
188
+ * - startCol: starting column in the logical line
189
+ * - length: length of this visual line segment
190
+ */
191
+ private buildVisualLineMap;
192
+ /**
193
+ * Find the visual line index for the current cursor position.
194
+ */
195
+ private findCurrentVisualLine;
196
+ private moveCursor;
197
+ /**
198
+ * Scroll by a page (direction: -1 for up, 1 for down).
199
+ * Moves cursor by the page size while keeping it in bounds.
200
+ */
201
+ private pageScroll;
202
+ private moveWordBackwards;
203
+ /**
204
+ * Yank (paste) the most recent kill ring entry at cursor position.
205
+ */
206
+ private yank;
207
+ /**
208
+ * Cycle through kill ring (only works immediately after yank or yank-pop).
209
+ * Replaces the last yanked text with the previous entry in the ring.
210
+ */
211
+ private yankPop;
212
+ /**
213
+ * Insert text at cursor position (used by yank operations).
214
+ */
215
+ private insertYankedText;
216
+ /**
217
+ * Delete the previously yanked text (used by yank-pop).
218
+ * The yanked text is derived from killRing[end] since it hasn't been rotated yet.
219
+ */
220
+ private deleteYankedText;
221
+ private pushUndoSnapshot;
222
+ private undo;
223
+ /**
224
+ * Jump to the first occurrence of a character in the specified direction.
225
+ * Multi-line search. Case-sensitive. Skips the current cursor position.
226
+ */
227
+ private jumpToChar;
228
+ private moveWordForwards;
229
+ private isSlashMenuAllowed;
230
+ private isAtStartOfMessage;
231
+ private isInSlashCommandContext;
232
+ private tryTriggerAutocomplete;
233
+ private handleTabCompletion;
234
+ private handleSlashCommandCompletion;
235
+ private forceFileAutocomplete;
236
+ private cancelAutocomplete;
237
+ isShowingAutocomplete(): boolean;
238
+ private updateAutocomplete;
239
+ }
240
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/components/editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAgC,MAAM,oBAAoB,CAAC;AAI7F,OAAO,EAAE,KAAK,SAAS,EAAiB,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIpE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAqExE;AAoDD,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,UAAU,EAAE,eAAe,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,qBAAa,MAAO,YAAW,SAAS,EAAE,SAAS;IAClD,OAAO,CAAC,KAAK,CAIX;IAEF,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAS;IAEzB,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAG7B,OAAO,CAAC,SAAS,CAAc;IAG/B,OAAO,CAAC,YAAY,CAAa;IAG1B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAG5C,OAAO,CAAC,oB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