@adeildo/pi-look 5.7.2 → 5.8.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/package.json +2 -2
- package/src/render/fit.ts +1 -1
- package/src/render/format.ts +5 -5
- package/src/render/glyphs.ts +2 -2
- package/src/ui/header.ts +2 -2
- package/src/ui/tool-frame.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adeildo/pi-look",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Pi's start screen, a framed editor and the footer, redrawn around the data that matters and painted only with the theme's colours.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@adeildo/pi-kit": "5.
|
|
41
|
+
"@adeildo/pi-kit": "5.8.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@earendil-works/pi-ai": "*",
|
package/src/render/fit.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function fitRegions(
|
|
|
55
55
|
return joined.map((text) =>
|
|
56
56
|
text === ""
|
|
57
57
|
? ""
|
|
58
|
-
: truncateToWidth(text, Math.max(0, width - overhead), options.ellipsis ?? "
|
|
58
|
+
: truncateToWidth(text, Math.max(0, width - overhead), options.ellipsis ?? "..."),
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
package/src/render/format.ts
CHANGED
|
@@ -72,11 +72,11 @@ export function shortenPath(cwd: string, home: string | undefined, maxWidth: num
|
|
|
72
72
|
let kept = "";
|
|
73
73
|
for (let index = parts.length - 1; index > 0; index--) {
|
|
74
74
|
const candidate = `${sep}${parts[index] ?? ""}${kept}`;
|
|
75
|
-
if (visibleWidth(
|
|
75
|
+
if (visibleWidth(`...${candidate}`) > maxWidth) break;
|
|
76
76
|
kept = candidate;
|
|
77
77
|
}
|
|
78
78
|
if (kept === "") return truncateTail(parts.at(-1) ?? full, maxWidth);
|
|
79
|
-
return
|
|
79
|
+
return `...${kept}`;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export function basename(cwd: string): string {
|
|
@@ -92,7 +92,7 @@ export function truncateTail(text: string, maxWidth: number): string {
|
|
|
92
92
|
if (maxWidth <= 0) return "";
|
|
93
93
|
if (visibleWidth(text) <= maxWidth) return text;
|
|
94
94
|
const chars = [...text];
|
|
95
|
-
let width =
|
|
95
|
+
let width = 3;
|
|
96
96
|
let start = chars.length;
|
|
97
97
|
while (start > 0) {
|
|
98
98
|
const next = visibleWidth(chars[start - 1] ?? "");
|
|
@@ -100,10 +100,10 @@ export function truncateTail(text: string, maxWidth: number): string {
|
|
|
100
100
|
width += next;
|
|
101
101
|
start--;
|
|
102
102
|
}
|
|
103
|
-
return
|
|
103
|
+
return `...${chars.slice(start).join("")}`;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
export function fitWidth(text: string, width: number, ellipsis = "
|
|
106
|
+
export function fitWidth(text: string, width: number, ellipsis = "..."): string {
|
|
107
107
|
return truncateToWidth(text, Math.max(0, width), ellipsis);
|
|
108
108
|
}
|
|
109
109
|
|
package/src/render/glyphs.ts
CHANGED
|
@@ -76,7 +76,7 @@ export const NERD: Glyphs = {
|
|
|
76
76
|
fill: "█",
|
|
77
77
|
empty: "░",
|
|
78
78
|
levels: ["▂", "▃", "▄", "▅", "▆", "▇"],
|
|
79
|
-
ellipsis: "
|
|
79
|
+
ellipsis: "...",
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
export const UNICODE: Glyphs = {
|
|
@@ -106,7 +106,7 @@ export const UNICODE: Glyphs = {
|
|
|
106
106
|
fill: "█",
|
|
107
107
|
empty: "░",
|
|
108
108
|
levels: ["▂", "▃", "▄", "▅", "▆", "▇"],
|
|
109
|
-
ellipsis: "
|
|
109
|
+
ellipsis: "...",
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
export const ASCII: Glyphs = {
|
package/src/ui/header.ts
CHANGED
|
@@ -110,7 +110,7 @@ export class HeaderComponent implements Component {
|
|
|
110
110
|
const hints = HINTS()
|
|
111
111
|
.map((hint) => `${paint.role("brand", hint.key)} ${paint.dim(hint.does)}`)
|
|
112
112
|
.join(separator);
|
|
113
|
-
return [first, hints, ""].map((line) => truncateToWidth(` ${line}`, width, "
|
|
113
|
+
return [first, hints, ""].map((line) => truncateToWidth(` ${line}`, width, "..."));
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
#title(paint: Paint): string {
|
|
@@ -192,7 +192,7 @@ export function halfBlocks(pixels: readonly string[]): string[] {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
function pad(text: string, width: number): string {
|
|
195
|
-
const clipped = truncateToWidth(text, Math.max(0, width), "
|
|
195
|
+
const clipped = truncateToWidth(text, Math.max(0, width), "...");
|
|
196
196
|
return `${clipped}${" ".repeat(Math.max(0, width - visibleWidth(clipped)))}`;
|
|
197
197
|
}
|
|
198
198
|
|
package/src/ui/tool-frame.ts
CHANGED
|
@@ -358,7 +358,7 @@ function inside(lines: readonly string[], width: number, theme: Theme): string[]
|
|
|
358
358
|
const inner = room(width);
|
|
359
359
|
return trim(lines).map((line) => {
|
|
360
360
|
// Measuring is cheap, and cutting a line that already fits is not.
|
|
361
|
-
const text = visibleWidth(line) > inner ? truncateToWidth(line, inner, "
|
|
361
|
+
const text = visibleWidth(line) > inner ? truncateToWidth(line, inner, "...", true) : line;
|
|
362
362
|
const pad = " ".repeat(Math.max(0, inner - visibleWidth(text)));
|
|
363
363
|
return `${paint("\u2502")} ${text}${pad} ${paint("\u2502")}`;
|
|
364
364
|
});
|