ammachado opened a new pull request, #24237: URL: https://github.com/apache/camel/pull/24237
# Description Makes ANSI-colored output in the embedded shell panel of the Camel TUI readable on dark terminal themes (see https://issues.apache.org/jira/browse/CAMEL-23830). **Problem** In the shell panel, text echoed while typing a command (the command highlighter colors unrecognized commands red) and error output such as `Unknown command: x` rendered as a dim literal `RGB(136,0,0)`, barely legible on a dark background. The prompt itself was fine (`camel` orange, version green, `>` white). **Root cause** JLine's `ScreenTerminal` flattens named ANSI colors into a 12-bit (4-bit-per-channel) value stored in the cell attribute. `ShellPanel.convertAttrToStyle` expanded that value straight back into a literal RGB color, bypassing the host terminal's theme. Standard ANSI red (palette index 1, `0x800000`) therefore became a fixed dim `RGB(136,0,0)` instead of the terminal's themed, readable red. **Fix** When the 12-bit value matches one of the 16 standard ANSI palette colors, emit a terminal-themed `Color.ansi(AnsiColor.X)` instead of a literal RGB color, mirroring how `TuiHelper.applySgr` already maps SGR codes elsewhere in the TUI. True-color cells (such as the prompt's orange `0xF69123`) do not match the palette and keep their literal RGB value. The 16 encodings are derived from JLine's xterm palette (`Colors.DEFAULT_COLORS_256[0..15]`) reduced via `ScreenTerminal.col24` (the top nibble of each channel), e.g. red `0x800000` -> `0x800`, bright red `0xff0000` -> `0xf00`, white `0xc0c0c0` -> `0xccc`. **Tests** - New `ShellPanelColorTest`: pins all 16 ANSI encodings to their `AnsiColor`, asserts true-color values (e.g. the prompt orange `0xf92`) stay unmapped, and includes a regression guard that ANSI red resolves to a themed `Color.ansi(RED)` rather than the old dim RGB. **Docs** - No documentation change: `camel-jbang-tui.adoc` has no shell-panel section, and this is a readability fix with no change to any default, option, or API, so it does not warrant an upgrade-guide entry. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL-23830) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. --- _Submitted by Claude Code on behalf of Adriano Machado._ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
