@xynogen/pix-display 0.1.8 → 0.1.9
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/code-blocks.ts +10 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-display",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Pi core extension
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Pi core extension \u2014 paste chips, thinking blocks, and framed code rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"scripts": {
|
package/src/code-blocks.ts
CHANGED
|
@@ -87,13 +87,10 @@ function bodyLine(
|
|
|
87
87
|
layoutIndent: number,
|
|
88
88
|
theme: CodeFrameTheme,
|
|
89
89
|
): string {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return paintFrame(
|
|
94
|
-
theme,
|
|
95
|
-
`${theme.fg("borderMuted", "│")} ${content}${padding} ${theme.fg("borderMuted", "│")}`,
|
|
96
|
-
);
|
|
90
|
+
const content = truncateToWidth(stripLayoutWhitespace(line, layoutIndent), width, "…");
|
|
91
|
+
// Keep every code row free of frame glyphs and layout padding. Selection must
|
|
92
|
+
// copy only source text, including meaningful relative indentation in Python.
|
|
93
|
+
return paintFrame(theme, content);
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
/**
|
|
@@ -117,13 +114,11 @@ export function renderCodeFences(lines: string[], width: number, theme: CodeFram
|
|
|
117
114
|
const pad = Math.min(leadingSpaces(out[start] ?? ""), Math.floor((width - 12) / 2));
|
|
118
115
|
const frameWidth = Math.max(12, width - pad * 2);
|
|
119
116
|
const body = out.slice(start + 1, end);
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
pad,
|
|
126
|
-
);
|
|
117
|
+
const bodyIndents = body
|
|
118
|
+
.map((line) => plainText(line))
|
|
119
|
+
.filter((line) => line.trim().length > 0)
|
|
120
|
+
.map((line) => leadingSpaces(line));
|
|
121
|
+
const bodyIndent = bodyIndents.length > 0 ? Math.min(...bodyIndents) : 0;
|
|
127
122
|
const left = " ".repeat(pad);
|
|
128
123
|
const right = " ".repeat(Math.max(0, width - pad - frameWidth));
|
|
129
124
|
const framed: string[] = [];
|
|
@@ -133,7 +128,7 @@ export function renderCodeFences(lines: string[], width: number, theme: CodeFram
|
|
|
133
128
|
);
|
|
134
129
|
for (let index = start + 1; index < end; index++) {
|
|
135
130
|
framed.push(
|
|
136
|
-
`${oscSequences(out[index] ?? "")}${
|
|
131
|
+
`${oscSequences(out[index] ?? "")}${bodyLine(out[index] ?? "", width, bodyIndent, theme)}`,
|
|
137
132
|
);
|
|
138
133
|
}
|
|
139
134
|
framed.push(`${oscSequences(out[end] ?? "")}${left}${bottomBorder(frameWidth, theme)}${right}`);
|