Replace named Ratatui colors with RGB values
Project tests / check (push) Successful in 3m38s
Project tests / nix (push) Successful in 9m16s
Project tests / linux (push) Successful in 2m15s
Project tests / aur (push) Successful in 8m29s

Update docs, increase test count to 107, adjust flake.lock, and modify
rendering logic to use explicit Color::Rgb throughout the codebase.
This commit is contained in:
GarandPLG committed 2026-10-26 13:21:25 +01:00
1 parent b1f548e3d3
commit 851d3410dd
28 files changed
+282 -152

No files matched your search

+9 -4
View File
@@ -178,8 +178,13 @@ fn contextual_help_fits_normal_terminal_and_changes_when_route_is_selected() ->
#[test]
fn construction_and_recruitment_popups_render_semantic_text_colors() -> () {
for (key, name, status, status_color) in [
('b', "Mine", "Construction unavailable", Color::Red),
('r', "Miner", "Enter: queue Miner", Color::Green),
(
'b',
"Mine",
"Construction unavailable",
Color::Rgb(128, 0, 0),
),
('r', "Miner", "Enter: queue Miner", Color::Rgb(0, 128, 0)),
] {
let mut app: App = app();
if key == 'r' {
@@ -194,8 +199,8 @@ fn construction_and_recruitment_popups_render_semantic_text_colors() -> () {
.unwrap();
let cells: &[Cell] = &terminal.backend().buffer().content;
for (text, color) in [
(name, Color::LightMagenta),
("Cost:", Color::Yellow),
(name, Color::Rgb(255, 0, 255)),
("Cost:", Color::Rgb(128, 128, 0)),
(status, status_color),
] {
assert!(
+1 -1
View File
@@ -92,7 +92,7 @@ fn base_cell_shows_recruitment_progress_until_spawn_at_every_zoom() -> () {
.find(|cell: &&Cell| -> bool { cell.symbol() == "%" })
.unwrap()
.fg,
Color::Cyan
Color::Rgb(0, 128, 128)
);
if zoom != ZoomLevel::ZoomedOut {
assert!(text(&buffer).contains('M'));
+47 -1
View File
@@ -53,10 +53,56 @@ fn route_color_count(app: &mut App) -> usize {
.buffer()
.content
.iter()
.filter(|cell: &&Cell| -> bool { matches!(cell.fg, Color::Magenta | Color::LightMagenta) })
.filter(|cell: &&Cell| -> bool {
matches!(cell.fg, Color::Rgb(128, 0, 128) | Color::Rgb(255, 0, 255))
})
.count()
}
#[test]
fn focused_queued_route_is_yellow_until_drawing_a_task() -> () {
let mut app: App = app();
let board: &mut BoardState = &mut app.states_mut().unwrap().skirmish.board;
board.cells[5][3].set_structure(Structures::Tunnel(Tunnel::new()));
board.cells[5][2]
.get_mut_option_unit()
.set_task(Tasks::Moving(MovingTask::new([(5, 3)].into())));
board.change_focused_cell(MoveFocusedCell::Right);
for drawing in [false, true] {
if drawing {
press(&mut app, KeyCode::Left);
press(&mut app, KeyCode::Char(' '));
}
let board: &BoardState = &app.states_ref().unwrap().skirmish.board;
assert_eq!(board.get_focused_cell().get_coords(), (5, 3));
for stress in [false, true] {
app.states_mut().unwrap().skirmish.stress_view = stress;
let mut terminal: Terminal<TestBackend> =
Terminal::new(TestBackend::new(160, 50)).unwrap();
terminal
.draw(|frame: &mut ratatui::Frame<'_>| -> () {
frame.render_widget(&mut app, frame.area());
})
.unwrap();
let corner: &Cell = &terminal
.backend()
.buffer()
.content
.windows(3)
.find(|cells: &&[Cell]| -> bool {
cells[0].symbol() == "╭" && cells[1].symbol() == "D" && cells[2].symbol() == "5"
})
.unwrap()[0];
let expected: Color = if drawing {
Color::Rgb(128, 0, 128)
} else {
Color::Rgb(255, 255, 0)
};
assert_eq!(corner.fg, expected);
}
}
}
#[test]
fn queued_route_colors_follow_progress_and_cancellation_without_marking_model() -> () {
let mut app: App = app();
+8 -4
View File
@@ -447,7 +447,7 @@ fn rubble_can_be_dug_again_and_auto_setting_survives_task_conversion() -> () {
}
#[test]
fn stress_view_hides_all_other_text_and_colors_but_keeps_focused_color() -> () {
fn stress_view_shows_coordinates_and_stress_but_keeps_focused_color() -> () {
let mut app: App = app();
let game: &mut SkirmishState = &mut app.states_mut().unwrap().skirmish;
put_tunnel(&mut game.board, (5, 3), true);
@@ -477,21 +477,25 @@ fn stress_view_hides_all_other_text_and_colors_but_keeps_focused_color() -> () {
.map(|cell: &Cell| -> &str { cell.symbol() })
.collect();
assert!(text.contains("20%"));
assert!(text.contains("D5"));
assert!(!text.contains('M') && !text.contains('T'));
assert!(!buffer.content.iter().any(|cell: &Cell| -> bool {
matches!(cell.fg, Color::Magenta | Color::LightMagenta | Color::Blue)
matches!(
cell.fg,
Color::Rgb(128, 0, 128) | Color::Rgb(255, 0, 255) | Color::Rgb(0, 0, 128)
)
}));
game.board.cells[5][3]
.clone()
.set_selected(true)
.render_stress(area, &mut buffer);
assert_eq!(buffer[(0, 0)].fg, Color::LightYellow);
assert_eq!(buffer[(0, 0)].fg, Color::Rgb(255, 255, 0));
game.board.cells[5][3]
.clone()
.set_selected(true)
.set_marked(true)
.render_stress(area, &mut buffer);
assert_eq!(buffer[(0, 0)].fg, Color::Magenta);
assert_eq!(buffer[(0, 0)].fg, Color::Rgb(128, 0, 128));
}
}