Skip to content

fix: leave terminal default foreground for uncolored text#87

Merged
natemoo-re merged 3 commits into
mainfrom
nm/repro/default-foreground
Jun 5, 2026
Merged

fix: leave terminal default foreground for uncolored text#87
natemoo-re merged 3 commits into
mainfrom
nm/repro/default-foreground

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Jun 5, 2026

Copy link
Copy Markdown
Member
  • Fixes 🐛 Uncolored text is forced to white instead of the terminal's default foreground #62
  • Uncolored text was packed as concrete white (0xFFFFFFFF), forcing a white foreground on light-background terminals
  • When color is absent, ops.ts now writes 0 and sets ATTR_DEFAULT (0x80) in the attrs byte; the existing C path ORs it into fg and emit_attr skips the foreground SGR — mirroring how an unset background is already left alone
  • Single-file change (ops.ts); explicitly-colored text is unchanged
  • Test plan: deno test green (8 passed); repro test/default-foreground.test.ts passes; deno lint + deno fmt --check clean

@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/clayterm@87

commit: 6e38018

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Size Increased — +0.3 KB

107.5 KB unpacked

Text with no explicit color was packed as concrete white
(0xFFFFFFFF), forcing white on light-background terminals. Encode
absent color as ATTR_DEFAULT (0x80 in the attrs byte) so the C path
skips the foreground SGR entirely, mirroring how an unset background
is already left alone.

Fixes #62
@natemoo-re natemoo-re force-pushed the nm/repro/default-foreground branch from 6994f81 to d9f71e2 Compare June 5, 2026 06:14
Just testing text attributes, shouldn't need an enclosing box.
@cowboyd cowboyd force-pushed the nm/repro/default-foreground branch from ffe8c33 to 6e38018 Compare June 5, 2026 19:28

@cowboyd cowboyd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I shortened up the test since it doesn't really need a bounding box in order to test text properties

@natemoo-re natemoo-re merged commit 48ff4bb into main Jun 5, 2026
12 checks passed
@natemoo-re natemoo-re deleted the nm/repro/default-foreground branch June 5, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Uncolored text is forced to white instead of the terminal's default foreground

2 participants