mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
db89b73a9c
This PR replicates the `tui` code directory and creates a temporary parallel `tui_app_server` directory. It also implements a new feature flag `tui_app_server` to select between the two tui implementations. Once the new app-server-based TUI is stabilized, we'll delete the old `tui` directory and feature flag.
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
use crate::color::blend;
|
|
use crate::color::is_light;
|
|
use crate::terminal_palette::best_color;
|
|
use crate::terminal_palette::default_bg;
|
|
use ratatui::style::Color;
|
|
use ratatui::style::Style;
|
|
|
|
pub fn user_message_style() -> Style {
|
|
user_message_style_for(default_bg())
|
|
}
|
|
|
|
pub fn proposed_plan_style() -> Style {
|
|
proposed_plan_style_for(default_bg())
|
|
}
|
|
|
|
/// Returns the style for a user-authored message using the provided terminal background.
|
|
pub fn user_message_style_for(terminal_bg: Option<(u8, u8, u8)>) -> Style {
|
|
match terminal_bg {
|
|
Some(bg) => Style::default().bg(user_message_bg(bg)),
|
|
None => Style::default(),
|
|
}
|
|
}
|
|
|
|
pub fn proposed_plan_style_for(terminal_bg: Option<(u8, u8, u8)>) -> Style {
|
|
match terminal_bg {
|
|
Some(bg) => Style::default().bg(proposed_plan_bg(bg)),
|
|
None => Style::default(),
|
|
}
|
|
}
|
|
|
|
#[allow(clippy::disallowed_methods)]
|
|
pub fn user_message_bg(terminal_bg: (u8, u8, u8)) -> Color {
|
|
let (top, alpha) = if is_light(terminal_bg) {
|
|
((0, 0, 0), 0.04)
|
|
} else {
|
|
((255, 255, 255), 0.12)
|
|
};
|
|
best_color(blend(top, terminal_bg, alpha))
|
|
}
|
|
|
|
#[allow(clippy::disallowed_methods)]
|
|
pub fn proposed_plan_bg(terminal_bg: (u8, u8, u8)) -> Color {
|
|
user_message_bg(terminal_bg)
|
|
}
|