@@ -59,20 +59,65 @@ public class LoginCommand implements Command<CommandInvocation> {
5959## Colorized Output
6060
6161``` java
62+ import org.aesh.readline.terminal.formatting.TerminalColor ;
63+ import org.aesh.readline.terminal.formatting.TerminalString ;
64+ import org.aesh.readline.terminal.formatting.TerminalTextStyle ;
65+ import org.aesh.readline.terminal.formatting.CharacterType ;
66+ import org.aesh.readline.terminal.formatting.Color ;
67+
6268public class ColorizedRenderer implements OptionRenderer<ProcessedOption > {
6369
6470 @Override
6571 public String render (ProcessedOption option ) {
6672 TerminalString colorized = new TerminalString (
6773 option. getValue(),
68- TerminalColor . DEFAULT_TEXT ,
69- TerminalTextStyle . INTENSITY_BOLD
74+ new TerminalColor ( Color . CYAN , Color . DEFAULT ) ,
75+ new TerminalTextStyle ( CharacterType . BOLD )
7076 );
7177 return colorized. toString();
7278 }
7379}
7480```
7581
82+ ### Theme-Aware Rendering
83+
84+ For colors that adapt to the terminal's light or dark theme, use the semantic color methods with detected terminal capabilities:
85+
86+ ``` java
87+ import org.aesh.readline.terminal.TerminalColorDetector ;
88+ import org.aesh.readline.terminal.formatting.TerminalColor ;
89+ import org.aesh.readline.terminal.formatting.TerminalString ;
90+ import org.aesh.terminal.utils.TerminalColorCapability ;
91+
92+ public class AdaptiveRenderer implements OptionRenderer<ProcessedOption > {
93+ private final TerminalColorCapability capability;
94+
95+ public AdaptiveRenderer (TerminalColorCapability capability ) {
96+ this . capability = capability;
97+ }
98+
99+ @Override
100+ public String render (ProcessedOption option ) {
101+ // Use theme-aware colors that work on both light and dark backgrounds
102+ TerminalColor color = TerminalColor . forHighlight(capability);
103+ return new TerminalString (option. getValue(), color). toString();
104+ }
105+ }
106+ ```
107+
108+ The semantic color methods automatically choose appropriate brightness:
109+
110+ | Method | Dark Theme | Light Theme | Use For |
111+ | --------| ------------| -------------| ---------|
112+ | ` forError() ` | Bright red | Normal red | Error messages |
113+ | ` forSuccess() ` | Bright green | Normal green | Success confirmations |
114+ | ` forWarning() ` | Bright yellow | Normal yellow | Warnings |
115+ | ` forInfo() ` | Bright cyan | Normal blue | Informational text |
116+ | ` forHighlight() ` | Bright white | Black | Emphasized text |
117+ | ` forMuted() ` | Normal white | Normal black | Secondary text |
118+
119+ See the Readline [ Terminal Colors] ( /docs/readline/terminal-colors ) documentation for more details on RGB colors and color depth adaptation.
120+
76121## Conditional Rendering
77122
78123``` java
0 commit comments