@sagmans/dsh-tui 0.2.0 → 0.4.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 (174) hide show
  1. package/README.md +282 -25
  2. package/cordis.patch.yml +14 -0
  3. package/lib/agent/model.d.ts +26 -0
  4. package/lib/agent/model.d.ts.map +1 -1
  5. package/lib/agent/model.js +41 -0
  6. package/lib/agent/model.js.map +1 -1
  7. package/lib/agent/projections.d.ts +22 -6
  8. package/lib/agent/projections.d.ts.map +1 -1
  9. package/lib/agent/projections.js +21 -10
  10. package/lib/agent/projections.js.map +1 -1
  11. package/lib/agent/prompt-history.d.ts +89 -0
  12. package/lib/agent/prompt-history.d.ts.map +1 -0
  13. package/lib/agent/prompt-history.js +380 -0
  14. package/lib/agent/prompt-history.js.map +1 -0
  15. package/lib/agent/status.d.ts +16 -0
  16. package/lib/agent/status.d.ts.map +1 -1
  17. package/lib/agent/status.js +3 -0
  18. package/lib/agent/status.js.map +1 -1
  19. package/lib/cards.d.ts +1 -1
  20. package/lib/cards.d.ts.map +1 -1
  21. package/lib/cards.js +4 -3
  22. package/lib/cards.js.map +1 -1
  23. package/lib/gates.d.ts +145 -2
  24. package/lib/gates.d.ts.map +1 -1
  25. package/lib/gates.js +335 -40
  26. package/lib/gates.js.map +1 -1
  27. package/lib/herdr/client.d.ts +57 -0
  28. package/lib/herdr/client.d.ts.map +1 -0
  29. package/lib/herdr/client.js +218 -0
  30. package/lib/herdr/client.js.map +1 -0
  31. package/lib/herdr/constants.d.ts +93 -0
  32. package/lib/herdr/constants.d.ts.map +1 -0
  33. package/lib/herdr/constants.js +79 -0
  34. package/lib/herdr/constants.js.map +1 -0
  35. package/lib/herdr/reporter.d.ts +60 -0
  36. package/lib/herdr/reporter.d.ts.map +1 -0
  37. package/lib/herdr/reporter.js +217 -0
  38. package/lib/herdr/reporter.js.map +1 -0
  39. package/lib/herdr/state.d.ts +57 -0
  40. package/lib/herdr/state.d.ts.map +1 -0
  41. package/lib/herdr/state.js +62 -0
  42. package/lib/herdr/state.js.map +1 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +631 -118
  45. package/lib/index.js.map +1 -1
  46. package/lib/input/actions.d.ts +136 -0
  47. package/lib/input/actions.d.ts.map +1 -0
  48. package/lib/input/actions.js +743 -0
  49. package/lib/input/actions.js.map +1 -0
  50. package/lib/input/ghost.d.ts +46 -0
  51. package/lib/input/ghost.d.ts.map +1 -0
  52. package/lib/input/ghost.js +58 -0
  53. package/lib/input/ghost.js.map +1 -0
  54. package/lib/input/keymap-settings.d.ts +21 -0
  55. package/lib/input/keymap-settings.d.ts.map +1 -0
  56. package/lib/input/keymap-settings.js +28 -0
  57. package/lib/input/keymap-settings.js.map +1 -0
  58. package/lib/input/keymap.d.ts +91 -0
  59. package/lib/input/keymap.d.ts.map +1 -0
  60. package/lib/input/keymap.js +172 -0
  61. package/lib/input/keymap.js.map +1 -0
  62. package/lib/input/match.d.ts +10 -0
  63. package/lib/input/match.d.ts.map +1 -0
  64. package/lib/input/match.js +83 -0
  65. package/lib/input/match.js.map +1 -0
  66. package/lib/input/submission.d.ts +29 -1
  67. package/lib/input/submission.d.ts.map +1 -1
  68. package/lib/input/submission.js +33 -2
  69. package/lib/input/submission.js.map +1 -1
  70. package/lib/input.d.ts +17 -0
  71. package/lib/input.d.ts.map +1 -0
  72. package/lib/input.js +27 -0
  73. package/lib/input.js.map +1 -0
  74. package/lib/keys-command.d.ts +16 -0
  75. package/lib/keys-command.d.ts.map +1 -0
  76. package/lib/keys-command.js +60 -0
  77. package/lib/keys-command.js.map +1 -0
  78. package/lib/queue.d.ts +6 -0
  79. package/lib/queue.d.ts.map +1 -0
  80. package/lib/queue.js +68 -0
  81. package/lib/queue.js.map +1 -0
  82. package/lib/settings-notice.d.ts +19 -0
  83. package/lib/settings-notice.d.ts.map +1 -0
  84. package/lib/settings-notice.js +30 -0
  85. package/lib/settings-notice.js.map +1 -0
  86. package/lib/stash/lock.d.ts +72 -0
  87. package/lib/stash/lock.d.ts.map +1 -0
  88. package/lib/stash/lock.js +374 -0
  89. package/lib/stash/lock.js.map +1 -0
  90. package/lib/stash/paths.d.ts +22 -0
  91. package/lib/stash/paths.d.ts.map +1 -0
  92. package/lib/stash/paths.js +83 -0
  93. package/lib/stash/paths.js.map +1 -0
  94. package/lib/stash/private-fs.d.ts +61 -0
  95. package/lib/stash/private-fs.d.ts.map +1 -0
  96. package/lib/stash/private-fs.js +379 -0
  97. package/lib/stash/private-fs.js.map +1 -0
  98. package/lib/stash/schema.d.ts +57 -0
  99. package/lib/stash/schema.d.ts.map +1 -0
  100. package/lib/stash/schema.js +127 -0
  101. package/lib/stash/schema.js.map +1 -0
  102. package/lib/stash/store.d.ts +92 -0
  103. package/lib/stash/store.d.ts.map +1 -0
  104. package/lib/stash/store.js +262 -0
  105. package/lib/stash/store.js.map +1 -0
  106. package/lib/stash.d.ts +91 -0
  107. package/lib/stash.d.ts.map +1 -0
  108. package/lib/stash.js +296 -0
  109. package/lib/stash.js.map +1 -0
  110. package/lib/theme-settings.d.ts +72 -8
  111. package/lib/theme-settings.d.ts.map +1 -1
  112. package/lib/theme-settings.js +125 -5
  113. package/lib/theme-settings.js.map +1 -1
  114. package/lib/theme-tokens.d.ts +4 -4
  115. package/lib/theme-tokens.d.ts.map +1 -1
  116. package/lib/theme-tokens.js +39 -5
  117. package/lib/theme-tokens.js.map +1 -1
  118. package/lib/todo-guard.d.ts +116 -0
  119. package/lib/todo-guard.d.ts.map +1 -0
  120. package/lib/todo-guard.js +259 -0
  121. package/lib/todo-guard.js.map +1 -0
  122. package/lib/ui/editor.d.ts +58 -1
  123. package/lib/ui/editor.d.ts.map +1 -1
  124. package/lib/ui/editor.js +174 -19
  125. package/lib/ui/editor.js.map +1 -1
  126. package/lib/ui/frame.d.ts +54 -0
  127. package/lib/ui/frame.d.ts.map +1 -0
  128. package/lib/ui/frame.js +79 -0
  129. package/lib/ui/frame.js.map +1 -0
  130. package/lib/ui/gate-input.d.ts +20 -0
  131. package/lib/ui/gate-input.d.ts.map +1 -0
  132. package/lib/ui/gate-input.js +96 -0
  133. package/lib/ui/gate-input.js.map +1 -0
  134. package/lib/ui/history-picker.d.ts +15 -0
  135. package/lib/ui/history-picker.d.ts.map +1 -0
  136. package/lib/ui/history-picker.js +26 -0
  137. package/lib/ui/history-picker.js.map +1 -0
  138. package/lib/ui/markdown.d.ts +11 -2
  139. package/lib/ui/markdown.d.ts.map +1 -1
  140. package/lib/ui/markdown.js +25 -6
  141. package/lib/ui/markdown.js.map +1 -1
  142. package/lib/ui/mermaid.d.ts +44 -0
  143. package/lib/ui/mermaid.d.ts.map +1 -0
  144. package/lib/ui/mermaid.js +178 -0
  145. package/lib/ui/mermaid.js.map +1 -0
  146. package/lib/ui/picker.d.ts +40 -8
  147. package/lib/ui/picker.d.ts.map +1 -1
  148. package/lib/ui/picker.js +79 -24
  149. package/lib/ui/picker.js.map +1 -1
  150. package/lib/ui/prompt.d.ts +32 -0
  151. package/lib/ui/prompt.d.ts.map +1 -0
  152. package/lib/ui/prompt.js +49 -0
  153. package/lib/ui/prompt.js.map +1 -0
  154. package/lib/ui/queue.d.ts +24 -0
  155. package/lib/ui/queue.d.ts.map +1 -0
  156. package/lib/ui/queue.js +57 -0
  157. package/lib/ui/queue.js.map +1 -0
  158. package/lib/ui/stash-picker.d.ts +43 -0
  159. package/lib/ui/stash-picker.d.ts.map +1 -0
  160. package/lib/ui/stash-picker.js +78 -0
  161. package/lib/ui/stash-picker.js.map +1 -0
  162. package/lib/ui/status.d.ts +6 -0
  163. package/lib/ui/status.d.ts.map +1 -1
  164. package/lib/ui/status.js +15 -0
  165. package/lib/ui/status.js.map +1 -1
  166. package/lib/ui/view.d.ts +22 -2
  167. package/lib/ui/view.d.ts.map +1 -1
  168. package/lib/ui/view.js +84 -24
  169. package/lib/ui/view.js.map +1 -1
  170. package/lib/work.d.ts +51 -1
  171. package/lib/work.d.ts.map +1 -1
  172. package/lib/work.js +53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EAAE,QAAQ,CAAC,OAAO,EAAE;SACxE,CAAC,EAAE,UAAU,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,4 +1,29 @@
1
1
  import { Editor, type EditorTheme, type TUI, type TuiMouseEvent, type TuiMouseEventResult } from '@earendil-works/pi-tui';
2
+ import { type Keymap } from '../input/actions.ts';
3
+ import { type EditorCursor } from '../input/ghost.ts';
4
+ /** Which run of a ghost is being drawn: the cursor cell, or the text after it. */
5
+ export type GhostCell = 'cursor' | 'rest';
6
+ /** What the bar knows when it asks for a suggestion. */
7
+ export interface GhostRequest {
8
+ readonly text: string;
9
+ readonly lines: readonly string[];
10
+ readonly cursor: EditorCursor;
11
+ }
12
+ /**
13
+ * The recorded-prompt suggestion the bar offers, and how to draw it.
14
+ *
15
+ * Kept as a collaborator rather than built in: the editor owns where the text
16
+ * goes, while the surface owns where the entries come from and which shade they
17
+ * are drawn in, so neither has to know the other's world.
18
+ */
19
+ export interface GhostBrush {
20
+ /** Whether the affordance may draw at all; colour and settings decide this. */
21
+ enabled(): boolean;
22
+ /** The suffix to offer after the typed text, or undefined for none. */
23
+ suggestion(input: GhostRequest): string | undefined;
24
+ /** Paint one run of the suffix; '' leaves the run undrawn. */
25
+ paint(text: string, cell: GhostCell): string;
26
+ }
2
27
  /**
3
28
  * The input bar drawn as a box, with its completion menu above it.
4
29
  *
@@ -8,17 +33,49 @@ import { Editor, type EditorTheme, type TUI, type TuiMouseEvent, type TuiMouseEv
8
33
  * while writing: a list that grows upward never covers the line being typed.
9
34
  */
10
35
  export declare class BoxedEditor extends Editor {
36
+ private readonly keymap;
37
+ private readonly ghost?;
11
38
  /** Rows the menu took in the last render; a click there belongs to the list. */
12
39
  private menuRows;
13
40
  /** Rows between the rules in the last render; how the base editor counts its own. */
14
41
  private textRows;
15
42
  /** Whether the last render drew a frame, which is what a click is mapped through. */
16
43
  private boxed;
17
- constructor(tui: TUI, theme: EditorTheme);
44
+ constructor(tui: TUI, theme: EditorTheme, keymap?: () => Keymap, ghost?: GhostBrush | undefined);
45
+ /**
46
+ * Read the two presses the base class cannot place on its own.
47
+ *
48
+ * Enter breaks the line while the reader keeps that key for the line, so the
49
+ * press the base would submit with becomes a newline — except while it is
50
+ * picking a completion, the one press that chooses something instead of
51
+ * sending it, and except on a bar a question or a picker has borrowed, whose
52
+ * keys belong to whoever borrowed it.
53
+ */
54
+ handleInput(data: string): void;
18
55
  /** Tag the closing rule so {@link render} can find where the box ends. */
19
56
  protected renderBottomBorder(width: number, hiddenLineCount: number): string;
20
57
  /** A rule redrawn as a box edge, so the corners carry the border's own colour. */
21
58
  private edge;
59
+ /**
60
+ * Rewrite one row of the text before it is framed, so a subclass can hide
61
+ * what it collects without hiding the box the reader types inside.
62
+ */
63
+ protected decorateText(row: string): string;
64
+ /** The suggestion to draw this paint, or undefined when the brush offers none. */
65
+ private currentGhostSuffix;
66
+ /**
67
+ * Replace the end-of-text cursor cell with the offered suffix.
68
+ *
69
+ * The base draws the cursor as one reverse-video cell and pads the rest of the
70
+ * row; the suffix takes that cell plus the padding after it, so the row keeps
71
+ * exactly its width and the cursor stays where the reader is typing.
72
+ */
73
+ private ghostRow;
74
+ /**
75
+ * Take a ghost-accepting key before the base sees it, so the key returns to
76
+ * its own meaning the moment nothing is offered.
77
+ */
78
+ private acceptGhost;
22
79
  render(width: number): string[];
23
80
  /**
24
81
  * Map a click back through the frame and the lifted menu.
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/ui/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,KAAK,WAAW,EAChB,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAA;AA4B/B;;;;;;;GAOG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,gFAAgF;IAChF,OAAO,CAAC,QAAQ,CAAI;IACpB,qFAAqF;IACrF,OAAO,CAAC,QAAQ,CA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AOG;AACH,qBAAa,WAAY,SAAQ,MAAM;IAWnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAXzB,gFAAgF;IAChF,OAAO,CAAC,QAAQ,CAAI;IACpB,qFAAqF;IACrF,OAAO,CAAC,QAAQ,CAAI;IACpB,qFAAqF;IACrF,OAAO,CAAC,KAAK,CAAQ;gBAGnB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,WAAW,EACD,MAAM,GAAE,MAAM,MAAsB,EACpC,KAAK,CAAC,EAAE,UAAU,YAAA;IAKrC;;;;;;;;OAQG;IACM,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAkCxC,0EAA0E;cACvD,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;IAIrF,kFAAkF;IAClF,OAAO,CAAC,IAAI;IAIZ;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI3C,kFAAkF;IAClF,OAAO,CAAC,kBAAkB;IAiB1B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IA0BhB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAgBV,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IA4BxC;;;;;;;;OAQG;IACM,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,mBAAmB,GAAG,SAAS;CAQ5E"}
package/lib/ui/editor.js CHANGED
@@ -1,16 +1,9 @@
1
- import { Editor, stripTerminalSequences, } from '@earendil-works/pi-tui';
2
- /** The frame the input bar is closed into: two corners per edge, one glyph per side. */
3
- const TOP_LEFT = '╭';
4
- const TOP_RIGHT = '╮';
5
- const BOTTOM_LEFT = '╰';
6
- const BOTTOM_RIGHT = '╯';
7
- const SIDE = '│';
8
- /** The frame costs one column each side, so the text wraps that much narrower. */
9
- const FRAME_COLUMNS = 2;
10
- /** One column of air inside the frame, so a full line never touches the border. */
11
- const PADDING_X = 1;
12
- /** A box needs both edges, both paddings, and one column left to type in. */
13
- const MIN_BOX_WIDTH = FRAME_COLUMNS + PADDING_X * 2 + 1;
1
+ import { Editor, getKeybindings, isKittyProtocolActive, matchesKey, stripTerminalSequences, visibleWidth, } from '@earendil-works/pi-tui';
2
+ import { ENTER_KEY, defaultKeymap } from "../input/actions.js";
3
+ import { ghostDisplayLine, ghostGraphemes, isCursorAtTextEnd, nextGhostWord } from "../input/ghost.js";
4
+ import { promptKeys } from "../input/keymap.js";
5
+ import { displayText } from "../text.js";
6
+ import { FRAME_COLUMNS, FRAME_GLYPHS, MIN_BOX_WIDTH, PADDING_X } from "./frame.js";
14
7
  /**
15
8
  * Marks the rule that closes the input while one render is in flight.
16
9
  *
@@ -22,6 +15,36 @@ const MIN_BOX_WIDTH = FRAME_COLUMNS + PADDING_X * 2 + 1;
22
15
  * pass removes it.
23
16
  */
24
17
  const CLOSING_TAG = '\u0000';
18
+ /**
19
+ * The line feed a plain Enter is handed to the base class as.
20
+ *
21
+ * The base owns what a newline does to paste markers, history, and undo, and it
22
+ * reads this byte as one in every terminal mode, including the modes where it
23
+ * no longer calls Enter itself a newline.
24
+ */
25
+ const NEWLINE_BYTE = '\n';
26
+ /** The one sequence a terminal that reports no modifiers sends for alt+enter. */
27
+ const LEGACY_ALT_ENTER = '\u001b\r';
28
+ /**
29
+ * The chords as the keyboard protocol spells them.
30
+ *
31
+ * The base class reads a legacy alt+enter and a bare line feed as line breaks
32
+ * before it looks at any binding, so each press is handed over as the chord the
33
+ * map actually holds for it. The submit path then runs whole, with the same
34
+ * guards a real chord meets, instead of a second sender beside it.
35
+ */
36
+ const KITTY_ALT_ENTER = '\u001b[13;3u';
37
+ const KITTY_CTRL_J = '\u001b[106;5u';
38
+ /**
39
+ * The cell the base editor draws for a cursor parked past the last character.
40
+ *
41
+ * Ghost text takes that cell over: the base offers no seam for "style the text
42
+ * after the cursor", so one paint pass finds the cell it drew and replaces the
43
+ * padding after it. The cell looks the same when the cursor sits over a typed
44
+ * space, which is why a caller also confirms the cursor is past the last
45
+ * character before treating the sequence as padding.
46
+ */
47
+ const CURSOR_AT_END = '\u001b[7m \u001b[0m';
25
48
  /**
26
49
  * The input bar drawn as a box, with its completion menu above it.
27
50
  *
@@ -31,14 +54,61 @@ const CLOSING_TAG = '\u0000';
31
54
  * while writing: a list that grows upward never covers the line being typed.
32
55
  */
33
56
  export class BoxedEditor extends Editor {
57
+ keymap;
58
+ ghost;
34
59
  /** Rows the menu took in the last render; a click there belongs to the list. */
35
60
  menuRows = 0;
36
61
  /** Rows between the rules in the last render; how the base editor counts its own. */
37
62
  textRows = 0;
38
63
  /** Whether the last render drew a frame, which is what a click is mapped through. */
39
64
  boxed = false;
40
- constructor(tui, theme) {
65
+ constructor(tui, theme, keymap = defaultKeymap, ghost) {
41
66
  super(tui, theme, { paddingX: PADDING_X });
67
+ this.keymap = keymap;
68
+ this.ghost = ghost;
69
+ }
70
+ /**
71
+ * Read the two presses the base class cannot place on its own.
72
+ *
73
+ * Enter breaks the line while the reader keeps that key for the line, so the
74
+ * press the base would submit with becomes a newline — except while it is
75
+ * picking a completion, the one press that chooses something instead of
76
+ * sending it, and except on a bar a question or a picker has borrowed, whose
77
+ * keys belong to whoever borrowed it.
78
+ */
79
+ handleInput(data) {
80
+ if (this.disableSubmit) {
81
+ super.handleInput(data);
82
+ return;
83
+ }
84
+ if (this.acceptGhost(data))
85
+ return;
86
+ const keys = promptKeys(this.keymap());
87
+ // A bare line feed is a line break in the base class whatever the map says,
88
+ // so a reader who moved the line break off ctrl+j and sends with it would
89
+ // keep getting lines. It is read before the Return guard because a terminal
90
+ // without the protocol reports that byte as Return as well — and only
91
+ // without it, because a terminal that speaks the protocol sends the chord
92
+ // itself and reports a line feed for a key the reader meant as a line.
93
+ if (data === NEWLINE_BYTE && !isKittyProtocolActive() && keys.submit.includes('ctrl+j')) {
94
+ super.handleInput(KITTY_CTRL_J);
95
+ return;
96
+ }
97
+ if (keys.enterBreaksLine && matchesKey(data, ENTER_KEY) && !this.isShowingAutocomplete()) {
98
+ super.handleInput(NEWLINE_BYTE);
99
+ return;
100
+ }
101
+ // Only while the terminal cannot tell alt+enter apart from a mapping, and
102
+ // only for the reader who bound that key: with the protocol active the same
103
+ // sequence is the reader's shift+enter, and a bar that answered it as a send
104
+ // because some other chord contains the same bytes would be submitting a key
105
+ // the reader never bound. A reader who keeps the sequence for a line is
106
+ // answered by the library's own rule.
107
+ if (data === LEGACY_ALT_ENTER && !isKittyProtocolActive() && keys.submit.includes('alt+enter')) {
108
+ super.handleInput(KITTY_ALT_ENTER);
109
+ return;
110
+ }
111
+ super.handleInput(data);
42
112
  }
43
113
  /** Tag the closing rule so {@link render} can find where the box ends. */
44
114
  renderBottomBorder(width, hiddenLineCount) {
@@ -48,14 +118,99 @@ export class BoxedEditor extends Editor {
48
118
  edge(open, close, row) {
49
119
  return this.borderColor(`${open}${stripTerminalSequences(row)}${close}`);
50
120
  }
121
+ /**
122
+ * Rewrite one row of the text before it is framed, so a subclass can hide
123
+ * what it collects without hiding the box the reader types inside.
124
+ */
125
+ decorateText(row) {
126
+ return row;
127
+ }
128
+ /** The suggestion to draw this paint, or undefined when the brush offers none. */
129
+ currentGhostSuffix() {
130
+ const brush = this.ghost;
131
+ if (brush === undefined || !brush.enabled())
132
+ return undefined;
133
+ const lines = this.getLines();
134
+ const cursor = this.getCursor();
135
+ // A cursor parked over a typed space draws the same cell as one at the very
136
+ // end, so the position has to be confirmed before a brush is asked at all.
137
+ if (!isCursorAtTextEnd({ lines, cursor }))
138
+ return undefined;
139
+ // The brush is a collaborator this class does not own, and its answer is
140
+ // both drawn and inserted: a control sequence would reach the terminal or
141
+ // the bar itself. The store refuses them too, so this only has to hold for
142
+ // any other brush. The expanded text is what was actually written; a large
143
+ // paste is stored as a marker and would otherwise match nothing.
144
+ const suffix = brush.suggestion({ text: this.getExpandedText(), lines, cursor });
145
+ return suffix === undefined ? undefined : displayText(suffix);
146
+ }
147
+ /**
148
+ * Replace the end-of-text cursor cell with the offered suffix.
149
+ *
150
+ * The base draws the cursor as one reverse-video cell and pads the rest of the
151
+ * row; the suffix takes that cell plus the padding after it, so the row keeps
152
+ * exactly its width and the cursor stays where the reader is typing.
153
+ */
154
+ ghostRow(row, suffix) {
155
+ const brush = this.ghost;
156
+ if (brush === undefined || suffix === undefined)
157
+ return row;
158
+ const cursorAt = row.indexOf(CURSOR_AT_END);
159
+ if (cursorAt < 0)
160
+ return row;
161
+ const before = row.slice(0, cursorAt);
162
+ const pad = visibleWidth(row.slice(cursorAt + CURSOR_AT_END.length));
163
+ // The freed cursor cell is one more column the suffix may fill.
164
+ const room = pad + 1;
165
+ // A width-aware cut can split a wide grapheme or return the escape that
166
+ // closed a style, so the fit is measured one grapheme at a time; when even
167
+ // the first one is too wide, the row keeps the cursor the base drew.
168
+ let drawn = '';
169
+ let used = 0;
170
+ for (const grapheme of ghostGraphemes(ghostDisplayLine(suffix))) {
171
+ const width = visibleWidth(grapheme);
172
+ if (used + width > room)
173
+ break;
174
+ drawn += grapheme;
175
+ used += width;
176
+ }
177
+ if (drawn === '')
178
+ return row;
179
+ const [first = '', ...rest] = ghostGraphemes(drawn);
180
+ const spaces = ' '.repeat(Math.max(0, room - used));
181
+ return before + brush.paint(first, 'cursor') + brush.paint(rest.join(''), 'rest') + spaces;
182
+ }
183
+ /**
184
+ * Take a ghost-accepting key before the base sees it, so the key returns to
185
+ * its own meaning the moment nothing is offered.
186
+ */
187
+ acceptGhost(data) {
188
+ const suffix = this.currentGhostSuffix();
189
+ if (suffix === undefined)
190
+ return false;
191
+ if (getKeybindings().matches(data, 'tui.editor.cursorWordRight')) {
192
+ const word = nextGhostWord(suffix);
193
+ if (word === undefined)
194
+ return false;
195
+ this.insertTextAtCursor(word);
196
+ this.tui.requestRender();
197
+ return true;
198
+ }
199
+ if (!matchesKey(data, 'ctrl+e'))
200
+ return false;
201
+ this.insertTextAtCursor(suffix);
202
+ this.tui.requestRender();
203
+ return true;
204
+ }
51
205
  render(width) {
52
- const side = this.borderColor(SIDE);
206
+ const side = this.borderColor(FRAME_GLYPHS.side);
53
207
  // A frame narrower than its own furniture would eat the text it exists to
54
208
  // hold, and a hidden border token asks for no frame at all: both cases keep
55
209
  // the plain rules rather than reserve columns for what nobody can see.
210
+ const ghost = this.disableSubmit ? undefined : this.currentGhostSuffix();
56
211
  if (width < MIN_BOX_WIDTH || side === '') {
57
212
  this.boxed = false;
58
- return super.render(width);
213
+ return super.render(width).map(row => this.decorateText(this.ghostRow(row, ghost)));
59
214
  }
60
215
  const rows = super.render(width - FRAME_COLUMNS);
61
216
  const closing = rows.findIndex(row => row.includes(CLOSING_TAG));
@@ -70,10 +225,10 @@ export class BoxedEditor extends Editor {
70
225
  this.boxed = true;
71
226
  // The menu keeps the page's own width; only its rows moved above the box.
72
227
  const lines = menu.map(row => row + ' '.repeat(FRAME_COLUMNS));
73
- lines.push(this.edge(TOP_LEFT, TOP_RIGHT, rows[0] ?? ''));
228
+ lines.push(this.edge(FRAME_GLYPHS.topLeft, FRAME_GLYPHS.topRight, rows[0] ?? ''));
74
229
  for (const row of text)
75
- lines.push(`${side}${row}${side}`);
76
- lines.push(this.edge(BOTTOM_LEFT, BOTTOM_RIGHT, rows[closing].replace(CLOSING_TAG, '')));
230
+ lines.push(`${side}${this.decorateText(this.ghostRow(row, ghost))}${side}`);
231
+ lines.push(this.edge(FRAME_GLYPHS.bottomLeft, FRAME_GLYPHS.bottomRight, rows[closing].replace(CLOSING_TAG, '')));
77
232
  return lines;
78
233
  }
79
234
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../src/ui/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,sBAAsB,GAKvB,MAAM,wBAAwB,CAAA;AAE/B,wFAAwF;AACxF,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,MAAM,WAAW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C,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,WAAW,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAA;QAC/E,CAAC;QACD,OAAO,KAAK,CAAC,WAAW,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3F,CAAC;CACF"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The frame every prompt is closed into.
3
+ *
4
+ * The editor, the prompts queued above it, and the prompts already submitted
5
+ * draw the same glyphs at the same width, so one prompt reads as the same object
6
+ * through its whole life; keeping the shape here is what stops the three from
7
+ * drifting.
8
+ */
9
+ export declare const FRAME_GLYPHS: {
10
+ readonly topLeft: "╭";
11
+ readonly topRight: "╮";
12
+ readonly bottomLeft: "╰";
13
+ readonly bottomRight: "╯";
14
+ readonly side: "│";
15
+ };
16
+ /** The frame costs one column each side, so the text wraps that much narrower. */
17
+ export declare const FRAME_COLUMNS = 2;
18
+ /** One column of air inside the frame, so a full line never touches the border. */
19
+ export declare const PADDING_X = 1;
20
+ /** A box needs both edges, both paddings, and one column left to type in. */
21
+ export declare const MIN_BOX_WIDTH: number;
22
+ /** The columns the text of a bar owns, given the width of everything inside its frame. */
23
+ export declare function textWidth(innerWidth: number): number;
24
+ /** One text row of a bar: the air, the text, and the rest of the inside width. */
25
+ export declare function textRow(text: string, innerWidth: number): string;
26
+ /**
27
+ * The rule that closes a bar, naming what the bar could not fit.
28
+ *
29
+ * A hidden count is a fact about the text, not extra text, so it rides the rule
30
+ * the way the editor's own scroll indicator does: the same label in the same
31
+ * place, at the same width, so both bars report a fold identically.
32
+ */
33
+ export declare function frameRule(innerWidth: number, hiddenRows: number): string;
34
+ /** How one block of text paints itself inside the bar that carries it. */
35
+ export interface FrameFaces {
36
+ /** Paints one row of the block's own text. */
37
+ readonly text: (line: string) => string;
38
+ /** Paints the frame's rules and its two sides. */
39
+ readonly border: (rule: string) => string;
40
+ /** Whether the frame may be drawn at all. */
41
+ readonly framed: boolean;
42
+ }
43
+ /** Whether a bar has the width, and the visible border, to close a frame. */
44
+ export declare function canFrame(width: number, borderVisible: boolean): boolean;
45
+ /**
46
+ * One block of text as a bar draws it: wrapped to the frame's own width, and
47
+ * closed into it when the frame can be drawn.
48
+ *
49
+ * A block with a limit is a preview, and the rows it drops are counted on the
50
+ * closing rule: a reader who cannot see the whole text still has to see that it
51
+ * continues. A block without a limit is the prompt itself, which is never cut.
52
+ */
53
+ export declare function frameText(text: string, width: number, faces: FrameFaces, limit?: number): string[];
54
+ //# sourceMappingURL=frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/ui/frame.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;;;;;;CAAyF,CAAA;AAElH,kFAAkF;AAClF,eAAO,MAAM,aAAa,IAAI,CAAA;AAC9B,mFAAmF;AACnF,eAAO,MAAM,SAAS,IAAI,CAAA;AAC1B,6EAA6E;AAC7E,eAAO,MAAM,aAAa,QAAoC,CAAA;AAE9D,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAgBxE;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACvC,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO,CAEvE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,SAA2B,GAAG,MAAM,EAAE,CAYpH"}
@@ -0,0 +1,79 @@
1
+ import { visibleWidth, wrapTextWithAnsi } from '@earendil-works/pi-tui';
2
+ import { displayText } from "../text.js";
3
+ /**
4
+ * The frame every prompt is closed into.
5
+ *
6
+ * The editor, the prompts queued above it, and the prompts already submitted
7
+ * draw the same glyphs at the same width, so one prompt reads as the same object
8
+ * through its whole life; keeping the shape here is what stops the three from
9
+ * drifting.
10
+ */
11
+ export const FRAME_GLYPHS = { topLeft: '╭', topRight: '╮', bottomLeft: '╰', bottomRight: '╯', side: '│' };
12
+ /** The frame costs one column each side, so the text wraps that much narrower. */
13
+ export const FRAME_COLUMNS = 2;
14
+ /** One column of air inside the frame, so a full line never touches the border. */
15
+ export const PADDING_X = 1;
16
+ /** A box needs both edges, both paddings, and one column left to type in. */
17
+ export const MIN_BOX_WIDTH = FRAME_COLUMNS + PADDING_X * 2 + 1;
18
+ /** The columns the text of a bar owns, given the width of everything inside its frame. */
19
+ export function textWidth(innerWidth) {
20
+ return Math.max(1, innerWidth - PADDING_X * 2);
21
+ }
22
+ /** One text row of a bar: the air, the text, and the rest of the inside width. */
23
+ export function textRow(text, innerWidth) {
24
+ const room = Math.max(0, textWidth(innerWidth) - visibleWidth(text));
25
+ return `${' '.repeat(PADDING_X)}${text}${' '.repeat(room)}${' '.repeat(PADDING_X)}`;
26
+ }
27
+ /**
28
+ * The rule that closes a bar, naming what the bar could not fit.
29
+ *
30
+ * A hidden count is a fact about the text, not extra text, so it rides the rule
31
+ * the way the editor's own scroll indicator does: the same label in the same
32
+ * place, at the same width, so both bars report a fold identically.
33
+ */
34
+ export function frameRule(innerWidth, hiddenRows) {
35
+ const width = Math.max(0, innerWidth);
36
+ if (hiddenRows <= 0)
37
+ return '─'.repeat(width);
38
+ const label = ` ↓ ${hiddenRows} more `;
39
+ const labelWidth = visibleWidth(label);
40
+ if (labelWidth + 2 <= width) {
41
+ const left = Math.floor((width - labelWidth) / 2);
42
+ return `${'─'.repeat(left)}${label}${'─'.repeat(width - left - labelWidth)}`;
43
+ }
44
+ // Too narrow for a centred label: name it as far as it fits instead of
45
+ // dropping the fact. Both the label and the fallback are ASCII, so slicing by
46
+ // character is slicing by column here.
47
+ const indicator = `─── ↓ ${hiddenRows} more `;
48
+ if (visibleWidth(indicator) <= width)
49
+ return indicator + '─'.repeat(width - visibleWidth(indicator));
50
+ const ellipsis = '...'.slice(0, width);
51
+ return indicator.slice(0, Math.max(0, width - ellipsis.length)) + ellipsis;
52
+ }
53
+ /** Whether a bar has the width, and the visible border, to close a frame. */
54
+ export function canFrame(width, borderVisible) {
55
+ return borderVisible && width >= MIN_BOX_WIDTH;
56
+ }
57
+ /**
58
+ * One block of text as a bar draws it: wrapped to the frame's own width, and
59
+ * closed into it when the frame can be drawn.
60
+ *
61
+ * A block with a limit is a preview, and the rows it drops are counted on the
62
+ * closing rule: a reader who cannot see the whole text still has to see that it
63
+ * continues. A block without a limit is the prompt itself, which is never cut.
64
+ */
65
+ export function frameText(text, width, faces, limit = Number.POSITIVE_INFINITY) {
66
+ const inside = faces.framed ? width - FRAME_COLUMNS : width;
67
+ const wrapped = wrapTextWithAnsi(displayText(text), textWidth(inside));
68
+ const body = wrapped.slice(0, Math.max(0, limit));
69
+ const rows = body.map(line => textRow(faces.text(line), inside));
70
+ if (!faces.framed)
71
+ return rows;
72
+ const side = faces.border(FRAME_GLYPHS.side);
73
+ return [
74
+ faces.border(`${FRAME_GLYPHS.topLeft}${frameRule(inside, 0)}${FRAME_GLYPHS.topRight}`),
75
+ ...rows.map(row => `${side}${row}${side}`),
76
+ faces.border(`${FRAME_GLYPHS.bottomLeft}${frameRule(inside, wrapped.length - body.length)}${FRAME_GLYPHS.bottomRight}`),
77
+ ];
78
+ }
79
+ //# sourceMappingURL=frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/ui/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAW,CAAA;AAElH,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;AAC9B,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAA;AAC1B,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,GAAG,SAAS,GAAG,CAAC,GAAG,CAAC,CAAA;AAE9D,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CAAC,UAAkB;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,CAAC,CAAC,CAAA;AAChD,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,UAAkB;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,GA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QAC1C,KAAK,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;KACxH,CAAA;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { BoxedEditor } from './editor.ts';
2
+ /** How a question's answer is shown while it is written. */
3
+ export type GateInputMode = 'answer' | 'secret';
4
+ /**
5
+ * The input bar a gate collects an answer with.
6
+ *
7
+ * It is the prompt bar's own component, so an answer is written with the
8
+ * movement, deletion, undo, and paste that bar already has. Its mode decides
9
+ * only how the answer is shown: a question that declares a credential is
10
+ * answered in the same bar with the middle of the value hidden, never in a
11
+ * second widget that would have to grow its own editing.
12
+ */
13
+ export declare class GateInputBar extends BoxedEditor {
14
+ private mode;
15
+ /** Switch what the bar shows without changing a character of what it holds. */
16
+ setMode(mode: GateInputMode): void;
17
+ /** Hide a credential's middle while its owner still recognizes both ends. */
18
+ protected decorateText(row: string): string;
19
+ }
20
+ //# sourceMappingURL=gate-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-input.d.ts","sourceRoot":"","sources":["../../src/ui/gate-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAA;AA2E/C;;;;;;;;GAQG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAC,IAAI,CAA0B;IAEtC,+EAA+E;IAC/E,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAMlC,6EAA6E;cAC1D,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAGrD"}
@@ -0,0 +1,96 @@
1
+ import { visibleWidth } from '@earendil-works/pi-tui';
2
+ import { BoxedEditor } from "./editor.js";
3
+ /** One character of the mask, repeated to the width of what it hides. */
4
+ const MASKED = '*';
5
+ /** How much of a credential stays readable at each end, so its owner can recognize it. */
6
+ const MASK_HEAD = 4;
7
+ const MASK_TAIL = 4;
8
+ /**
9
+ * A terminal sequence, so masking can tell a row's styling from its text: the
10
+ * cursor is drawn as an escape around a character, and hiding the character
11
+ * must not hide the mark that says where the cursor is.
12
+ *
13
+ * The string forms carry payloads a terminal reads rather than shows, and a
14
+ * cursor marker is one of them: masking a marker's own text would replace the
15
+ * position the terminal was told to place the cursor at with asterisks.
16
+ */
17
+ const SEQUENCE = /\u001b(?:\[[0-9;?]*[ -/]*[@-~]|[\][P_^X][^\u0007\u001b]*(?:\u0007|\u001b\\)|[@-Z\\-_])/gu;
18
+ const GRAPHEMES = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
19
+ /**
20
+ * One visible grapheme, and where it sits among the row's visible characters.
21
+ *
22
+ * Whitespace is not among them: the editor lays the answer out with spaces that
23
+ * belong to its own drawing, and hiding them would move the text under the
24
+ * cursor rather than hide it.
25
+ */
26
+ function visibleAt(text) {
27
+ const found = [];
28
+ let position = 0;
29
+ for (const { segment } of GRAPHEMES.segment(text)) {
30
+ if (segment.trim() === '') {
31
+ found.push({ segment, position: -1 });
32
+ continue;
33
+ }
34
+ found.push({ segment, position });
35
+ position += 1;
36
+ }
37
+ return found;
38
+ }
39
+ /**
40
+ * Hide the middle of a credential and keep its ends readable.
41
+ *
42
+ * The reader is checking which key they pasted, and a row of asterisks answers
43
+ * nothing; a bystander is not meant to read it either, so only the first and
44
+ * last few characters survive. Rows are masked one at a time because that is
45
+ * how the editor hands them over, and a credential is written on one line.
46
+ */
47
+ function maskCredentialRow(row) {
48
+ const segments = [];
49
+ let last = 0;
50
+ for (const match of row.matchAll(SEQUENCE)) {
51
+ segments.push({ escape: false, text: row.slice(last, match.index) });
52
+ segments.push({ escape: true, text: match[0] });
53
+ last = match.index + match[0].length;
54
+ }
55
+ segments.push({ escape: false, text: row.slice(last) });
56
+ const visible = segments.filter(segment => !segment.escape).flatMap(segment => visibleAt(segment.text));
57
+ const total = visible.reduce((count, entry) => count + (entry.position >= 0 ? 1 : 0), 0);
58
+ if (total <= MASK_HEAD + MASK_TAIL)
59
+ return row;
60
+ let seen = 0;
61
+ return segments.map((segment) => {
62
+ if (segment.escape)
63
+ return segment.text;
64
+ return visibleAt(segment.text).map((entry) => {
65
+ if (entry.position < 0)
66
+ return entry.segment;
67
+ const readable = seen < MASK_HEAD || seen >= total - MASK_TAIL;
68
+ seen += 1;
69
+ return readable ? entry.segment : MASKED.repeat(Math.max(1, visibleWidth(entry.segment)));
70
+ }).join('');
71
+ }).join('');
72
+ }
73
+ /**
74
+ * The input bar a gate collects an answer with.
75
+ *
76
+ * It is the prompt bar's own component, so an answer is written with the
77
+ * movement, deletion, undo, and paste that bar already has. Its mode decides
78
+ * only how the answer is shown: a question that declares a credential is
79
+ * answered in the same bar with the middle of the value hidden, never in a
80
+ * second widget that would have to grow its own editing.
81
+ */
82
+ export class GateInputBar extends BoxedEditor {
83
+ mode = 'answer';
84
+ /** Switch what the bar shows without changing a character of what it holds. */
85
+ setMode(mode) {
86
+ if (this.mode === mode)
87
+ return;
88
+ this.mode = mode;
89
+ this.invalidate();
90
+ }
91
+ /** Hide a credential's middle while its owner still recognizes both ends. */
92
+ decorateText(row) {
93
+ return this.mode === 'secret' ? maskCredentialRow(row) : row;
94
+ }
95
+ }
96
+ //# sourceMappingURL=gate-input.js.map