Use concrete default colors for face color pairs - #259
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaCurses.assume_default_colors. This works with ncurses, where-1is kept in the pair and resolved to the assumed default colors at render time. PDCursesMod, however, resolves-1to the terminal's original colors atinit_pairtime (_normalize()inpdcurses/color.c), and itsassume_default_colorsre-initializes only color pair 0. As a result, only plain text (pair 0) got the theme background.Fix
Facenow keeps the concrete default color numbers and substitutes them for-1when initializing color pairs.Window.set_default_colorsnotifiesFace, 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"),
-1is used as before, preserving terminal default/transparent backgrounds.🤖 Generated with Claude Code