Expand description
Helper functions for advanced table styling
This module provides utilities for applying cell-specific colors while
preserving the theme’s background colors. Use these when you need more
control than the simple OxurTable::new(data).render() pattern.
§Example: Cell-Specific Coloring
use oxur_cli::table::{helpers, TableStyleConfig, Builder, TabledColor, Tabled};
#[derive(Tabled)]
struct Row {
id: String,
name: String,
status: String,
}
// Build table manually
let mut builder = Builder::default();
builder.push_record(["ID", "Name", "Status"]);
builder.push_record(["001", "Alice", "Active"]);
builder.push_record(["002", "Bob", "Inactive"]);
let mut table = builder.build();
// Apply theme
let theme = TableStyleConfig::default();
theme.apply_to_table::<Row>(&mut table);
// Get row background colors from theme
let row_bg_colors = helpers::parse_row_bg_colors(&theme);
// Apply cell-specific colors to status column
let fg_color = TabledColor::FG_GREEN;
let bg_color = helpers::get_data_row_bg_color(0, &row_bg_colors);
helpers::apply_cell_color(&mut table, 2, 2, fg_color, bg_color);Functions§
- apply_
cell_ color - Apply a foreground color to a specific cell while preserving its background.
- deleted_
to_ fg_ color - Map a deleted boolean to a foreground color.
- get_
data_ row_ bg_ color - Get the background color for a data row using alternating colors.
- parse_
row_ bg_ colors - Parse row background colors from theme configuration.
- state_
to_ fg_ color - Map a state string to a foreground color.