@xynogen/pix-display 0.1.8 → 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 +2 -2
  2. package/src/code-blocks.ts +19 -29
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xynogen/pix-display",
3
- "version": "0.1.8",
4
- "description": "Pi core extension — paste chips, thinking blocks, and framed code rendering",
3
+ "version": "0.1.10",
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": {
@@ -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(
@@ -87,13 +87,10 @@ function bodyLine(
87
87
  layoutIndent: number,
88
88
  theme: CodeFrameTheme,
89
89
  ): string {
90
- const innerWidth = Math.max(1, width - 4);
91
- const content = truncateToWidth(stripLayoutWhitespace(line, layoutIndent), innerWidth, "…");
92
- const padding = " ".repeat(Math.max(0, innerWidth - visibleWidth(content)));
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
  /**
@@ -114,29 +111,22 @@ export function renderCodeFences(lines: string[], width: number, theme: CodeFram
114
111
  }
115
112
  if (end >= out.length) continue;
116
113
 
117
- const pad = Math.min(leadingSpaces(out[start] ?? ""), Math.floor((width - 12) / 2));
118
- const frameWidth = Math.max(12, width - pad * 2);
114
+ const frameWidth = width;
119
115
  const body = out.slice(start + 1, end);
120
- const bodyIndent = Math.min(
121
- ...body
122
- .map((line) => plainText(line))
123
- .filter((line) => line.trim().length > 0)
124
- .map((line) => leadingSpaces(line)),
125
- pad,
126
- );
127
- const left = " ".repeat(pad);
128
- const right = " ".repeat(Math.max(0, width - pad - frameWidth));
116
+ const bodyIndents = body
117
+ .map((line) => plainText(line))
118
+ .filter((line) => line.trim().length > 0)
119
+ .map((line) => leadingSpaces(line));
120
+ const bodyIndent = bodyIndents.length > 0 ? Math.min(...bodyIndents) : 0;
129
121
  const framed: string[] = [];
130
122
 
131
- framed.push(
132
- `${oscSequences(out[start] ?? "")}${left}${topBorder(frameWidth, language, theme)}${right}`,
133
- );
123
+ framed.push(`${oscSequences(out[start] ?? "")}${topRule(frameWidth, language, theme)}`);
134
124
  for (let index = start + 1; index < end; index++) {
135
125
  framed.push(
136
- `${oscSequences(out[index] ?? "")}${left}${bodyLine(out[index] ?? "", frameWidth, bodyIndent, theme)}${right}`,
126
+ `${oscSequences(out[index] ?? "")}${bodyLine(out[index] ?? "", width, bodyIndent, theme)}`,
137
127
  );
138
128
  }
139
- framed.push(`${oscSequences(out[end] ?? "")}${left}${bottomBorder(frameWidth, theme)}${right}`);
129
+ framed.push(`${oscSequences(out[end] ?? "")}${bottomRule(frameWidth, theme)}`);
140
130
 
141
131
  out.splice(start, end - start + 1, ...framed);
142
132
  start += framed.length - 1;