Skip to content

Support 256-color fallback for terminals without truecolor#755

Open
ryan-z wants to merge 2 commits intoanomalyco:mainfrom
ryan-z:feat/256-color-fallback
Open

Support 256-color fallback for terminals without truecolor#755
ryan-z wants to merge 2 commits intoanomalyco:mainfrom
ryan-z:feat/256-color-fallback

Conversation

@ryan-z
Copy link
Copy Markdown

@ryan-z ryan-z commented Feb 28, 2026

Problem

macOS Terminal.app does not support truecolor (24-bit RGB) by default, limiting colors to the standard 16 or 256 color palette. This makes it hard to see the full range of colors in opentui.

Solution

This PR adds a 256-color fallback:

  • Detects if the terminal supports truecolor via $COLORTERM environment variable
  • When truecolor is not available, converts RGB colors to the nearest 256-color palette index
  • Uses the 6x6x6 color cube (216 colors) and grayscale ramp (24 shades)

Use case

Running opentui in macOS Terminal.app and seeing more than 16 colors.

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