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:
115
src/config.rs
115
src/config.rs
@@ -24,6 +24,91 @@ pub enum ColumnAlignment {
|
||||
Center,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ContentArrangement {
|
||||
#[default]
|
||||
Dynamic,
|
||||
DynamicFullWidth,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TableStyle {
|
||||
#[default]
|
||||
Ascii,
|
||||
Utf8,
|
||||
Utf8Full,
|
||||
Nothing,
|
||||
Custom(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TableColor {
|
||||
Black,
|
||||
Red,
|
||||
Green,
|
||||
Yellow,
|
||||
Blue,
|
||||
Magenta,
|
||||
Cyan,
|
||||
White,
|
||||
Gray,
|
||||
DarkRed,
|
||||
DarkGreen,
|
||||
DarkYellow,
|
||||
DarkBlue,
|
||||
DarkMagenta,
|
||||
DarkCyan,
|
||||
Rgb(u8, u8, u8),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TableAttribute {
|
||||
Bold,
|
||||
Dim,
|
||||
Italic,
|
||||
Underlined,
|
||||
SlowBlink,
|
||||
RapidBlink,
|
||||
Reverse,
|
||||
Hidden,
|
||||
CrossedOut,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct TableConfig {
|
||||
#[serde(default)]
|
||||
pub style: TableStyle,
|
||||
#[serde(default)]
|
||||
pub modifiers: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub content_arrangement: ContentArrangement,
|
||||
#[serde(default)]
|
||||
pub truncation_indicator: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct ColumnConfig {
|
||||
pub name: String,
|
||||
pub label: String,
|
||||
#[serde(default)]
|
||||
pub align: ColumnAlignment,
|
||||
#[serde(default)]
|
||||
pub max_len: Option<String>,
|
||||
#[serde(default)]
|
||||
pub fg_color: Option<TableColor>,
|
||||
#[serde(default)]
|
||||
pub bg_color: Option<TableColor>,
|
||||
#[serde(default)]
|
||||
pub attributes: Vec<TableAttribute>,
|
||||
#[serde(default)]
|
||||
pub padding: Option<(u16, u16)>,
|
||||
}
|
||||
|
||||
impl<'de> serde::Deserialize<'de> for ColumnConfig {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
@@ -83,6 +168,8 @@ pub struct Settings {
|
||||
pub dir: PathBuf,
|
||||
pub list_format: Vec<ColumnConfig>,
|
||||
#[serde(default)]
|
||||
pub table_config: TableConfig,
|
||||
#[serde(default)]
|
||||
pub human_readable: bool,
|
||||
pub output_format: Option<String>,
|
||||
#[serde(default)]
|
||||
@@ -210,42 +297,70 @@ impl Settings {
|
||||
label: "Item".to_string(),
|
||||
align: ColumnAlignment::Right,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "time".to_string(),
|
||||
label: "Time".to_string(),
|
||||
align: ColumnAlignment::Right,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "size".to_string(),
|
||||
label: "Size".to_string(),
|
||||
align: ColumnAlignment::Right,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "meta:text_line_count".to_string(),
|
||||
label: "Lines".to_string(),
|
||||
align: ColumnAlignment::Right,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "tags".to_string(),
|
||||
label: "Tags".to_string(),
|
||||
align: ColumnAlignment::Left,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "meta:hostname_short".to_string(),
|
||||
label: "Host".to_string(),
|
||||
align: ColumnAlignment::Left,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
ColumnConfig {
|
||||
name: "meta:command".to_string(),
|
||||
label: "Command".to_string(),
|
||||
align: ColumnAlignment::Left,
|
||||
max_len: None,
|
||||
fg_color: None,
|
||||
bg_color: None,
|
||||
attributes: Vec::new(),
|
||||
padding: None,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user