[PR #755] Support 256-color fallback for terminals without truecolor #1538

Open
opened 2026-03-14 09:42:13 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/755
Author: @ryan-z
Created: 2/28/2026
Status: 🔄 Open

Base: mainHead: feat/256-color-fallback


📝 Commits (2)

  • 73952c7 feat: 256-color-fallback
  • d108647 refactor: optimize getCapabilities call and add tests

📊 Changes

4 files changed (+169 additions, -3 deletions)

View changed files

📝 packages/core/src/zig/ansi.zig (+91 -0)
📝 packages/core/src/zig/renderer.zig (+16 -3)
📝 packages/core/src/zig/test.zig (+2 -0)
packages/core/src/zig/tests/ansi_test.zig (+60 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/755 **Author:** [@ryan-z](https://github.com/ryan-z) **Created:** 2/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/256-color-fallback` --- ### 📝 Commits (2) - [`73952c7`](https://github.com/anomalyco/opentui/commit/73952c78831e7fea5b565fe69c50f74a0752c66a) feat: 256-color-fallback - [`d108647`](https://github.com/anomalyco/opentui/commit/d108647c91504064d28dc260b8b728d746aa092a) refactor: optimize getCapabilities call and add tests ### 📊 Changes **4 files changed** (+169 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/zig/ansi.zig` (+91 -0) 📝 `packages/core/src/zig/renderer.zig` (+16 -3) 📝 `packages/core/src/zig/test.zig` (+2 -0) ➕ `packages/core/src/zig/tests/ansi_test.zig` (+60 -0) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1538
No description provided.