@ravshansbox/pi-statusline 1.10.0 → 1.11.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/README.md +1 -1
- package/index.ts +32 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Pi loads the extension from `./index.ts`. It replaces the built-in footer with a
|
|
|
18
18
|
- token usage, cache hit rate and context usage
|
|
19
19
|
- statuses set by other extensions
|
|
20
20
|
|
|
21
|
-
It also replaces the editor
|
|
21
|
+
It also replaces the editor. The editor has no borders and shows `❯ ` before the prompt. It adds shell-style prompt history:
|
|
22
22
|
|
|
23
23
|
- **Up / Down** recall the previous / next prompt from earlier sessions in the current folder.
|
|
24
24
|
- **Ctrl+R** opens reverse search. Type to filter, Up/Down to move, Tab to switch between current-folder and all-folder history, Enter to load the prompt, Esc to cancel. Text already in the editor becomes the initial query.
|
package/index.ts
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
Text,
|
|
16
16
|
truncateToWidth,
|
|
17
17
|
type TUI,
|
|
18
|
+
type TuiMouseEvent,
|
|
19
|
+
type TuiMouseEventResult,
|
|
18
20
|
} from '@earendil-works/pi-tui';
|
|
19
21
|
import {
|
|
20
22
|
type HistoryScope,
|
|
@@ -73,6 +75,8 @@ function getUsage(ctx: ExtensionContext) {
|
|
|
73
75
|
return { totals, latestCacheHitRate };
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
const PROMPT = '\u276f ';
|
|
79
|
+
|
|
76
80
|
class HistoryEditor extends CustomEditor {
|
|
77
81
|
private prompts: string[] = [];
|
|
78
82
|
onReverseSearch?: () => void;
|
|
@@ -94,6 +98,34 @@ class HistoryEditor extends CustomEditor {
|
|
|
94
98
|
super.addToHistory(text);
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
private contentRows = 0;
|
|
102
|
+
|
|
103
|
+
protected override renderTopBorder(): string {
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
protected override renderBottomBorder(): string {
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
override render(width: number): string[] {
|
|
112
|
+
const lines = super.render(Math.max(1, width - PROMPT.length));
|
|
113
|
+
const bottom = lines.indexOf('', 1);
|
|
114
|
+
this.contentRows = bottom - 1;
|
|
115
|
+
return lines
|
|
116
|
+
.filter((_, i) => i !== 0 && i !== bottom)
|
|
117
|
+
.map((line, i) => (i === 0 ? PROMPT : ' '.repeat(PROMPT.length)) + line);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
override handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
121
|
+
return super.handleMouse({
|
|
122
|
+
...event,
|
|
123
|
+
x: event.x - PROMPT.length,
|
|
124
|
+
y: event.y < this.contentRows ? event.y + 1 : event.y + 2,
|
|
125
|
+
width: event.width - PROMPT.length,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
97
129
|
override handleInput(data: string): void {
|
|
98
130
|
if (matchesKey(data, 'ctrl+r')) {
|
|
99
131
|
this.onReverseSearch?.();
|