Skip to content

💡 narrow 16-color output against the terminal's real palette #152

Open

Description

@dreyfus92

Is your feature request related to a problem?

in the 16-color tier (#148), colors are narrowed against the nominal palette from color-encoding-spec §6.3.1, where index 0 is #000000. most themes redefine those entries though. catppuccin mocha draws index 0 as #45475a, which is lighter than its #1e1e2e background. so a dark panel on a dark theme comes out lighter than the terminal around it, and anything dark enough to snap to index 0 can collapse into its own background

repro (pinned to #148's preview build): https://stackblitz.com/edit/stackblitz-starters-gtbye9zp?file=index.js

it renders a dark panel (rgba(30, 32, 42)) with two text colors on it and prints the SGR it emits:

  • dim text: 90 40 40, the panel is index 0, so it's lighter than the theme bg
  • faint text (rgba(55, 58, 70)): 30 40 40, same index for text and background, so the text is invisible in every theme

i hit this building a command palette over a live app: the 55% dark scrim composited to ~#13131c, narrowed to index 0, and turned into a light gray slab. dim log text under it disappeared

Describe the solution you'd like

narrow against the colors the terminal actually uses. the probe could ask for indices 0–15 with OSC 4 (OSC 4 ; n ; ? ST, ghostty, kitty, iterm2 and xterm answer it) and the 16-color tier could pick the nearest real entry. the default fg/bg from OSC 10/11 are already probed, so they could be candidates too and emit 39/49 when they win, which would let a near-bg color stay the default bg instead of snapping to index 0

Describe alternatives you've considered

working around it in the app: in the demo i drop the scrim and shadow in the 16-color tier and draw the palette flat, which works but every app would need to know about it. a palette option on createTerm would also work but it's another thing the caller has to supply

Additional context

related to #60 and #129. screenshot of the scrim in 16 colors on catppuccin mocha attached

Image

AI assistance disclosure

  • This feature request was drafted with the assistance of an AI tool.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions