diff options
Diffstat (limited to 'src/config/ui.rs')
-rw-r--r-- | src/config/ui.rs | 102 |
1 files changed, 94 insertions, 8 deletions
diff --git a/src/config/ui.rs b/src/config/ui.rs index bab96f48..c7a39f42 100644 --- a/src/config/ui.rs +++ b/src/config/ui.rs @@ -3,13 +3,14 @@ use std::collections::HashMap; -use anyhow::{Error, Result}; +use anyhow::Result; use derivative::Derivative; use gtmpl::Template; use ini::{Ini, Properties}; use crate::config::columns::ColumnDef; use crate::config::style::StyleSet; +use crate::config::templates; #[derive(Derivative, Default)] #[derivative(Debug)] @@ -91,19 +92,104 @@ pub struct UiConfig { contextual_cache: HashMap<UiContextKey, UiConfig>, } -#[derive(Debug)] -struct UiContext {} +#[derive(Debug, Clone)] +struct UiContext { + // message list + pub index_columns: Vec<ColumnDef>, + pub column_separator: String, + pub empty_message: String, + pub threading_enabled: bool, + pub force_client_threads: bool, + pub client_threads_delay: time::Duration, + pub sort: Vec<String>, + pub reverse_order: bool, + pub reverse_thread_order: bool, + pub sort_thread_siblings: bool, + + // dirlist + #[derivative(Debug(format_with = "crate::config::templates::debug_template"))] + pub dirlist_left: Template, + #[derivative(Debug(format_with = "crate::config::templates::debug_template"))] + pub dirlist_right: Template, + pub sidebar_width: u8, + pub empty_dirlist: String, + pub dirlist_delay: time::Duration, + pub dirlist_tree: bool, + pub dirlist_collapse: u8, + + // time formats + pub timestamp_format: String, + pub this_day_time_format: String, + pub this_week_time_format: String, + pub this_year_time_format: String, + pub msgview_timestamp_format: String, + pub msgview_this_day_time_format: String, + pub msgview_this_week_time_format: String, + pub msgview_this_year_time_format: String, + + // icons + pub icon_unencrypted: String, + pub icon_encrypted: String, + pub icon_signed: String, + pub icon_signed_encrypted: String, + pub icon_unknown: String, + pub icon_invalid: String, + pub icon_attachment: String, + + // style + pub stylesets_dirs: Vec<String>, + pub styleset_name: String, + style: StyleSet, + + // general appearance + pub border_vertical: char, + pub border_horizontal: char, + pub spinner: String, + pub spinner_delimiter: String, + pub spinner_interval: time::Duration, + pub pinned_tab_marker: String, + + // behaviour + pub automark_read: bool, + pub next_message_on_delete: bool, + pub mouse_enabled: bool, + pub fuzzy_complete: bool, + pub new_message_bell: bool, + pub completion_delay: time::Duration, + pub completion_min_chars: u8, + pub completion_popovers: bool, -#[derive(Debug)] + // tabs + #[derivative(Debug(format_with = "crate::config::templates::debug_template"))] + pub tab_title_account: Template, + #[derivative(Debug(format_with = "crate::config::templates::debug_template"))] + pub tab_title_composer: Template, + + // contextual + contextual_counts: HashMap<UiContextType, usize>, + contextual_cache: HashMap<UiContextKey, UiConfig>, +} + +#[derive(Debug, Clone)] enum UiContextType {} -#[derive(Debug)] +#[derive(Debug, Clone)] struct UiContextKey {} impl UiConfig { pub fn parse(ini: &Ini) -> Result<Self> { - let ui = ini.section(Some("ui")).unwrap_or(&Properties::new()); - - Ok(Self::default()) + let empty = Properties::new(); + let ui = ini.section(Some("ui")).unwrap_or(&empty); + + Ok(UiConfig { + styleset_name: ui + .get_all("styleset") + .last() + .unwrap_or("default") + .to_string(), + tab_title_account: templates::parse_ini(ui, "tab-title-account", "{{.Account}}")?, + tab_title_composer: templates::parse_ini(ui, "tab-title-composer", "{{.Subject}}")?, + ..Default::default() + }) } } |