feat: Add comprehensive table styling options
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -171,3 +171,57 @@ pub fn create_table(use_styling: bool) -> Table {
|
||||
table
|
||||
}
|
||||
|
||||
/// Create a table using the provided table configuration
|
||||
pub fn create_table_with_config(table_config: &crate::config::TableConfig) -> Table {
|
||||
let mut table = Table::new();
|
||||
|
||||
// Set content arrangement
|
||||
match table_config.content_arrangement {
|
||||
ContentArrangement::Dynamic => table.set_content_arrangement(ContentArrangement::Dynamic),
|
||||
ContentArrangement::DynamicFullWidth => table.set_content_arrangement(ContentArrangement::DynamicFullWidth),
|
||||
ContentArrangement::Disabled => table.set_content_arrangement(ContentArrangement::Disabled),
|
||||
}
|
||||
|
||||
// Set style preset
|
||||
match &table_config.style {
|
||||
crate::config::TableStyle::Ascii => table.load_preset(comfy_table::presets::ASCII_FULL),
|
||||
crate::config::TableStyle::Utf8 => table.load_preset(comfy_table::presets::UTF8_FULL),
|
||||
crate::config::TableStyle::Utf8Full => table.load_preset(comfy_table::presets::UTF8_FULL),
|
||||
crate::config::TableStyle::Nothing => table.load_preset(comfy_table::presets::NOTHING),
|
||||
crate::config::TableStyle::Custom(preset) => {
|
||||
// For custom presets, we'd need to parse the string
|
||||
// This is a placeholder for custom preset handling
|
||||
if preset == "ASCII_FULL" {
|
||||
table.load_preset(comfy_table::presets::ASCII_FULL);
|
||||
} else if preset == "UTF8_FULL" {
|
||||
table.load_preset(comfy_table::presets::UTF8_FULL);
|
||||
} else if preset == "NOTHING" {
|
||||
table.load_preset(comfy_table::presets::NOTHING);
|
||||
}
|
||||
// Add more presets as needed
|
||||
}
|
||||
}
|
||||
|
||||
// Apply modifiers
|
||||
for modifier in &table_config.modifiers {
|
||||
match modifier.as_str() {
|
||||
"UTF8_SOLID_INNER_BORDERS" => table.apply_modifier(comfy_table::modifiers::UTF8_SOLID_INNER_BORDERS),
|
||||
"UTF8_ROUND_CORNERS" => table.apply_modifier(comfy_table::modifiers::UTF8_ROUND_CORNERS),
|
||||
"UTF8_NO_BORDERS" => table.apply_modifier(comfy_table::modifiers::UTF8_NO_BORDERS),
|
||||
"UTF8_NO_LINES" => table.apply_modifier(comfy_table::modifiers::UTF8_NO_LINES),
|
||||
_ => {} // Ignore unknown modifiers
|
||||
}
|
||||
}
|
||||
|
||||
// Set truncation indicator if specified
|
||||
if !table_config.truncation_indicator.is_empty() {
|
||||
table.set_truncation_indicator(&table_config.truncation_indicator);
|
||||
}
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
table.force_no_tty();
|
||||
}
|
||||
|
||||
table
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user