@xynogen/pix-pretty 1.7.2 → 1.7.3
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/package.json +1 -1
- package/src/progress.ts +14 -19
package/package.json
CHANGED
package/src/progress.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* p.close(); // releases input, removes overlay
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { frameLines, modalWidth } from "./modal-frame.js";
|
|
17
17
|
|
|
18
18
|
interface ProgressTheme {
|
|
19
19
|
fg(color: string, text: string): string;
|
|
@@ -66,31 +66,15 @@ export function openProgress(
|
|
|
66
66
|
ui.custom<void>(
|
|
67
67
|
(tui, theme, _kb, done) => {
|
|
68
68
|
let frame = 0;
|
|
69
|
-
const titleText = new Text(theme.fg(accent, theme.bold(title)), 1, 0);
|
|
70
|
-
const statusText = new Text("", 1, 0);
|
|
71
|
-
|
|
72
|
-
const render = () => {
|
|
73
|
-
statusText.setText(
|
|
74
|
-
`${theme.fg(accent, SPINNER[frame])} ${theme.fg("muted", labelValue)}`,
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
69
|
let labelValue = "Working…";
|
|
79
|
-
render();
|
|
80
70
|
|
|
81
71
|
const ticker = setInterval(() => {
|
|
82
72
|
frame = (frame + 1) % SPINNER.length;
|
|
83
|
-
render();
|
|
84
73
|
tui.requestRender();
|
|
85
74
|
}, SPINNER_INTERVAL_MS);
|
|
86
75
|
|
|
87
|
-
const container = new Box(2, 1, (s) => theme.bg("customMessageBg", s));
|
|
88
|
-
container.addChild(titleText);
|
|
89
|
-
container.addChild(statusText);
|
|
90
|
-
|
|
91
76
|
setLabelImpl = (label: string) => {
|
|
92
77
|
labelValue = label;
|
|
93
|
-
render();
|
|
94
78
|
tui.requestRender();
|
|
95
79
|
};
|
|
96
80
|
closeImpl = () => {
|
|
@@ -99,8 +83,19 @@ export function openProgress(
|
|
|
99
83
|
};
|
|
100
84
|
|
|
101
85
|
return {
|
|
102
|
-
render: (w: number) =>
|
|
103
|
-
|
|
86
|
+
render: (w: number) => {
|
|
87
|
+
const mw = modalWidth(w);
|
|
88
|
+
return frameLines({
|
|
89
|
+
width: mw,
|
|
90
|
+
lines: [
|
|
91
|
+
theme.fg(accent, theme.bold(title)),
|
|
92
|
+
`${theme.fg(accent, SPINNER[frame])} ${theme.fg("muted", labelValue)}`,
|
|
93
|
+
],
|
|
94
|
+
color: (s) => theme.fg(accent, s),
|
|
95
|
+
bg: (s) => theme.bg("customMessageBg", s),
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
invalidate: () => {},
|
|
104
99
|
// Swallow every keystroke: a focused overlay owns input, so nothing
|
|
105
100
|
// reaches the editor while the update runs.
|
|
106
101
|
handleInput: () => {},
|