pi-zen 0.1.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.
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/extensions/zen.ts +200 -0
- package/package.json +62 -0
- package/src/backgroundless-theme.ts +158 -0
- package/src/builtin-render.ts +69 -0
- package/src/call-group.ts +190 -0
- package/src/compact-tools.ts +565 -0
- package/src/display-path.ts +23 -0
- package/src/edit-diff.ts +169 -0
- package/src/editor-rail.ts +68 -0
- package/src/markdown-compaction.ts +40 -0
- package/src/silent-header.ts +15 -0
- package/src/thinking-tail.ts +51 -0
- package/src/tool-output.ts +184 -0
- package/src/tool-row.ts +124 -0
- package/src/working-indicator.ts +29 -0
- package/src/zen-editor.ts +40 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CustomEditor, type KeybindingsManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { EditorTheme, TUI } from "@earendil-works/pi-tui";
|
|
3
|
+
|
|
4
|
+
import { applyRail, MIN_RAIL_PADDING } from "./editor-rail.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Pi's editor with a rail instead of a frame.
|
|
8
|
+
*
|
|
9
|
+
* Every input behaviour comes from `CustomEditor`: app keybindings, history,
|
|
10
|
+
* paste handling, autocomplete, IME support, and cursor geometry are inherited
|
|
11
|
+
* untouched. Only the rendered rows are rewritten, and only in padding columns
|
|
12
|
+
* the base editor left blank.
|
|
13
|
+
*/
|
|
14
|
+
export class ZenEditor extends CustomEditor {
|
|
15
|
+
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
|
|
16
|
+
super(tui, theme, keybindings, { paddingX: MIN_RAIL_PADDING });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Keep enough padding for the rail.
|
|
21
|
+
*
|
|
22
|
+
* Pi copies the app's configured padding onto a custom editor, and its
|
|
23
|
+
* default is zero, which would leave the rail nowhere to sit.
|
|
24
|
+
*
|
|
25
|
+
* @param padding - Padding requested by the app.
|
|
26
|
+
*/
|
|
27
|
+
override setPaddingX(padding: number): void {
|
|
28
|
+
super.setPaddingX(Math.max(MIN_RAIL_PADDING, padding));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Render the editor with the Zen rail.
|
|
33
|
+
*
|
|
34
|
+
* @param width - Available terminal width.
|
|
35
|
+
* @returns The rows to draw.
|
|
36
|
+
*/
|
|
37
|
+
override render(width: number): string[] {
|
|
38
|
+
return applyRail(super.render(width), this.getPaddingX(), (glyph) => this.borderColor(glyph));
|
|
39
|
+
}
|
|
40
|
+
}
|