@xynogen/pix-display 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/code-blocks.ts +9 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-display",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Pi core extension \u2014 paste chips, thinking blocks, and framed code rendering",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -66,19 +66,19 @@ function fenceLabel(line: string): string | undefined {
66
66
  return info.split(/\s+/, 1)[0] || DEFAULT_LABEL;
67
67
  }
68
68
 
69
- function topBorder(width: number, language: string, theme: CodeFrameTheme): string {
70
- const available = Math.max(1, width - 6);
69
+ function topRule(width: number, language: string, theme: CodeFrameTheme): string {
70
+ const available = Math.max(1, width - 4);
71
71
  const displayLanguage = truncateToWidth(language, available, "…");
72
72
  const label = theme.bold(theme.fg("accent", ` ${displayLanguage} `));
73
- const ruleWidth = Math.max(0, width - visibleWidth(label) - 3);
73
+ const ruleWidth = Math.max(0, width - visibleWidth(label) - 2);
74
74
  return paintFrame(
75
75
  theme,
76
- `${theme.fg("borderMuted", "╭─")}${label}${theme.fg("borderMuted", `${"─".repeat(ruleWidth)}╮`)}`,
76
+ `${theme.fg("borderMuted", "──")}${label}${theme.fg("borderMuted", "─".repeat(ruleWidth))}`,
77
77
  );
78
78
  }
79
79
 
80
- function bottomBorder(width: number, theme: CodeFrameTheme): string {
81
- return paintFrame(theme, theme.fg("borderMuted", `╰${"─".repeat(Math.max(0, width - 2))}╯`));
80
+ function bottomRule(width: number, theme: CodeFrameTheme): string {
81
+ return paintFrame(theme, theme.fg("borderMuted", "─".repeat(width)));
82
82
  }
83
83
 
84
84
  function bodyLine(
@@ -111,27 +111,22 @@ export function renderCodeFences(lines: string[], width: number, theme: CodeFram
111
111
  }
112
112
  if (end >= out.length) continue;
113
113
 
114
- const pad = Math.min(leadingSpaces(out[start] ?? ""), Math.floor((width - 12) / 2));
115
- const frameWidth = Math.max(12, width - pad * 2);
114
+ const frameWidth = width;
116
115
  const body = out.slice(start + 1, end);
117
116
  const bodyIndents = body
118
117
  .map((line) => plainText(line))
119
118
  .filter((line) => line.trim().length > 0)
120
119
  .map((line) => leadingSpaces(line));
121
120
  const bodyIndent = bodyIndents.length > 0 ? Math.min(...bodyIndents) : 0;
122
- const left = " ".repeat(pad);
123
- const right = " ".repeat(Math.max(0, width - pad - frameWidth));
124
121
  const framed: string[] = [];
125
122
 
126
- framed.push(
127
- `${oscSequences(out[start] ?? "")}${left}${topBorder(frameWidth, language, theme)}${right}`,
128
- );
123
+ framed.push(`${oscSequences(out[start] ?? "")}${topRule(frameWidth, language, theme)}`);
129
124
  for (let index = start + 1; index < end; index++) {
130
125
  framed.push(
131
126
  `${oscSequences(out[index] ?? "")}${bodyLine(out[index] ?? "", width, bodyIndent, theme)}`,
132
127
  );
133
128
  }
134
- framed.push(`${oscSequences(out[end] ?? "")}${left}${bottomBorder(frameWidth, theme)}${right}`);
129
+ framed.push(`${oscSequences(out[end] ?? "")}${bottomRule(frameWidth, theme)}`);
135
130
 
136
131
  out.splice(start, end - start + 1, ...framed);
137
132
  start += framed.length - 1;