Skip to content

Use concrete default colors for face color pairs - #259

Merged
shugo merged 1 commit into
mainfrom
fix/face-default-colors-on-pdcurses
Aug 24, 2026
Merged

Use concrete default colors for face color pairs#259
shugo merged 1 commit into
mainfrom
fix/face-default-colors-on-pdcurses

Conversation

@shugo

@shugo shugo commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Problem

On Windows (curses gem with bundled PDCursesMod), faces without an explicit background (e.g. keyword) were rendered with the terminal's original background instead of the theme background.

Cause

Textbringer initializes color pairs for such faces with -1 (default color) and applies the theme background afterwards via Curses.assume_default_colors. This works with ncurses, where -1 is kept in the pair and resolved to the assumed default colors at render time. PDCursesMod, however, resolves -1 to the terminal's original colors at init_pair time (_normalize() in pdcurses/color.c), and its assume_default_colors re-initializes only color pair 0. As a result, only plain text (pair 0) got the theme background.

Fix

  • Face now keeps the concrete default color numbers and substitutes them for -1 when initializing color pairs.
  • Window.set_default_colors notifies Face, which re-resolves all faces when the default colors change.

No platform detection is needed: on ncurses the substituted colors equal the assumed defaults, so rendering is unchanged. When no theme is active (default colors are "default"), -1 is used as before, preserving terminal default/transparent backgrounds.

🤖 Generated with Claude Code

PDCurses resolves -1 at init_pair time and assume_default_colors
affects only color pair 0, so faces without explicit background kept
the terminal's original background instead of the theme background on
Windows. Substitute the concrete default colors for -1 in init_pair
and re-resolve all faces when the default colors change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@shugo
shugo merged commit b9ca78d into main Aug 24, 2026
7 checks passed
@shugo
shugo deleted the fix/face-default-colors-on-pdcurses branch August 24, 2026 07:01
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.

1 participant