Skip to content

Add styles to theme for completion item and metadata colors#1653

Open
tleonhardt wants to merge 9 commits intomainfrom
pt-colors
Open

Add styles to theme for completion item and metadata colors#1653
tleonhardt wants to merge 9 commits intomainfrom
pt-colors

Conversation

@tleonhardt
Copy link
Copy Markdown
Member

@tleonhardt tleonhardt commented Apr 24, 2026

Add styles to theme for completion item and metadata foreground and background colors.

This is an attempt to provide higher-contrast color options and to make them configurable as part of a theme.

Added rich_to_pt_style and rich_to_pt_color conversion helper functions to convert from rich color/style objects to prompt-toolkit color/style strings.

  • For ColorSystem.STANDARD colors (0-15), it maps directly to prompt-toolkit's ansicolor names (e.g. ansired, ansibrightred). This ensures that prompt-toolkit delegates to the terminal's theme for the basic 16 colors.
  • For ColorSystem.EIGHT_BIT and ColorSystem.TRUECOLOR, it falls back to parsing the RGB hex code (e.g., #ff0000), which prompt-toolkit supports natively.

…round color

This is an attempt to provide higher-contrast color options and to make them configurable as part of a theme.
@tleonhardt tleonhardt requested a review from kmvanbrunt as a code owner April 24, 2026 23:23
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.49%. Comparing base (a3890a7) to head (3bc0070).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1653   +/-   ##
=======================================
  Coverage   99.49%   99.49%           
=======================================
  Files          21       21           
  Lines        4741     4785   +44     
=======================================
+ Hits         4717     4761   +44     
  Misses         24       24           
Flag Coverage Δ
unittests 99.49% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Also:
- Cache prompt-toolkit completion menu styles for efficiency
- Fixed color check bug related to default terminal style
@kmvanbrunt kmvanbrunt marked this pull request as draft April 26, 2026 03:55
BRIGHT_GREEN is one of the standard 16 colors typically configured by a user's terminal theme.

LIGHT_GREEN is from the extended 256-color range.
Created a new converter function to safely extract the correct string representation for prompt-toolkit:

- For `ColorSystem.STANDARD` colors (0-15), it maps directly to `prompt-toolkit`'s `ansicolor` names (e.g. `ansired`, `ansibrightred`). This ensures that `prompt-toolkit` delegates to the terminal's theme for the basic 16 colors.
- For `ColorSystem.EIGHT_BIT` and `ColorSystem.TRUECOLOR`, it falls back to parsing the RGB hex code (e.g., `#ff0000`), which `prompt-toolkit` supports natively.

Also:
- Renamed `to_pt_style` to `rich_to_pt_style` to make its intent more obvious
- Added tests for the new `rich_to_pt_color` conversion function
@tleonhardt tleonhardt marked this pull request as ready for review April 26, 2026 19:13
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