@xynogen/pix-display 0.7.0 → 0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-display",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Pi core extension — inline chips, thinking blocks, and framed code rendering",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -100,7 +100,7 @@ function bottomRule(width: number, theme: CodeFrameTheme): string {
100
100
  return theme.fg("borderMuted", "─".repeat(width));
101
101
  }
102
102
 
103
- function bodyLine(line: string, width: number, layoutIndent: number): string {
103
+ function codeCell(line: string, width: number, layoutIndent: number): string {
104
104
  // Code column only; the caller prepends the same numbered gutter as the
105
105
  // file-content renderer.
106
106
  return truncateToWidth(stripLayoutWhitespace(line, layoutIndent), width, "…");
@@ -148,7 +148,7 @@ export function renderCodeFences(
148
148
  if (!isFoldedBlock) {
149
149
  for (let index = start + 1; index < end; index++) {
150
150
  framed.push(
151
- `${oscSequences(out[index] ?? "")}${lineGutter(index - start, numberWidth)}${bodyLine(out[index] ?? "", codeWidth, bodyIndent)}${RST}`,
151
+ `${oscSequences(out[index] ?? "")}${lineGutter(index - start, numberWidth)}${codeCell(out[index] ?? "", codeWidth, bodyIndent)}${RST}`,
152
152
  );
153
153
  }
154
154
  framed.push(`${oscSequences(out[end] ?? "")}${bottomRule(frameWidth, theme)}`);
package/src/code-frame.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Interactions on a code frame's header row: the arrow at the left folds the block,
3
- * the `copy` button at the right end writes its source to the system clipboard.
2
+ * Interactions on a code frame's header row: a click anywhere on the row folds the
3
+ * block, except the `copy` button at its right end, which writes the source to the
4
+ * system clipboard.
4
5
  *
5
6
  * Rows come from the same render that drew the frames, so a hit test cannot drift
6
7
  * from what the user sees. Display only: the session keeps the raw text.
@@ -66,20 +67,19 @@ function copyFrame(frame: CodeFrame): void {
66
67
  }
67
68
 
68
69
  /**
69
- * Left click on a frame's header: the arrow folds the block, the trailing `copy`
70
- * button writes it. Returns true when the click was ours.
70
+ * Left click on a frame's header row: the trailing `copy` button writes the block,
71
+ * anywhere else on the row folds it. Returns true when the click was ours.
71
72
  */
72
73
  export function frameClickAt(owner: Owner, event: Click): boolean {
73
74
  if (event.type !== "click" || event.button !== "left") return false;
74
75
  const frame = frames.get(owner)?.find((candidate) => candidate.row === event.y);
75
76
  if (!frame) return false;
76
- if (event.x < FOLD_ARROW) {
77
- if (folded.has(frame.text)) folded.delete(frame.text);
78
- else folded.add(frame.text);
79
- owner.invalidate?.();
77
+ if (event.x >= event.width - COPY_BUTTON.length) {
78
+ copyFrame(frame);
80
79
  return true;
81
80
  }
82
- if (event.x < event.width - COPY_BUTTON.length) return false;
83
- copyFrame(frame);
81
+ if (folded.has(frame.text)) folded.delete(frame.text);
82
+ else folded.add(frame.text);
83
+ owner.invalidate?.();
84
84
  return true;
85
85
  }