Skip to content

feat(theme): add color0-color255 syntax and fix 256-color palette, Fi…#2199

Open
Samyra312007 wants to merge 1 commit into
profanity-im:masterfrom
Samyra312007:feature/colorN-numeric-color-support
Open

feat(theme): add color0-color255 syntax and fix 256-color palette, Fi…#2199
Samyra312007 wants to merge 1 commit into
profanity-im:masterfrom
Samyra312007:feature/colorN-numeric-color-support

Conversation

@Samyra312007

Copy link
Copy Markdown

Fixes: #2081

Summary

Add color0 to color255 syntax support for addressing all 256 terminal colors by number, and fix the 256-color palette to match the actual xterm specification.

Changes

src/config/color.c

  • Fixed color values: Replaced all 256 HSL values in the color_names[] array with correct values derived from the standard xterm 256-color palette:

    • Colors 0–15: Standard ANSI defaults (e.g., red was hsl(0,100%,25%) = #800000, now hsl(0,100%,40%) = #CD0000)
    • Colors 16–231: 6×6×6 color cube computed from rgb({0,95,135,175,215,255})
    • Colors 232–255: 24-step grayscale ramp (rgb(8,8,8) to rgb(238,238,238))
    • Key fix: gold1 (index 220) was hsl(0,100%,50%) = pure red, now hsl(51,100%,50%) = correct gold
  • Added colorN syntax: Enhanced find_col() to parse color0 through color255 (case-insensitive), returning the numeric index directly. This solves the "fewer than 256 accessible colors" problem caused by duplicate names (e.g., blue3 at indices 19 and 20).

src/ui/console.c

  • Updated /theme colours: Replaced outdated help text with clear instructions on using color0 to color255 and the standard xterm colour names.

Backward Compatibility

  • All existing named colors are preserved unchanged
  • All existing .theme files continue to work without modification
  • The colorN syntax is purely additive

How to test the functionality

  1. Build with your usual flags: meson setup build_run -Dtests=true && meson compile -C build_run
  2. Run the tests: meson test -C build_run
  3. Launch profanity and run /theme colours — verify the updated help text appears
  4. Load a theme that uses numeric syntax, e.g. add this to a .theme file:
    [colours]
    titlebar=color21
    titlebar.text=color255
  5. Verify the colors render correctly
  6. Verify existing themes (e.g. themes/original) still work with named colors like gold1, navyblue, etc.

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.

Improve color support

1 participant