From 649fa3b6dc5d08f10e25260bf06d454e18aa6b04 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Sat, 3 May 2025 15:19:19 +0200 Subject: [PATCH] add support for markup solves #25 --- src/lib/config.rs | 24 ++++++++++++++++++------ src/lib/gui.rs | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/lib/config.rs b/src/lib/config.rs index c9acddc..b8cacf7 100644 --- a/src/lib/config.rs +++ b/src/lib/config.rs @@ -188,8 +188,9 @@ pub struct Config { #[clap(short = 'I', long = "allow-images")] allow_images: Option, + /// If `true` pango markup is parsed #[clap(short = 'm', long = "allow-markup")] - allow_markup: Option, // todo support this + allow_markup: Option, #[clap(short = 'k', long = "cache-file")] cache_file: Option, // todo support this @@ -223,8 +224,11 @@ pub struct Config { #[clap(short = 'M', long = "matching")] matching: Option, + /// Control if search is case insenstive or not. + /// Defaults to false #[clap(short = 'i', long = "insensitive")] - insensitive: Option, + #[serde(default = "default_true")] + insensitive: bool, #[clap(short = 'q', long = "parse-search")] parse_search: Option, // todo support this @@ -249,7 +253,7 @@ pub struct Config { sort_order: Option, #[clap(short = 'Q', long = "search")] - search: Option, // todo support this + search: Option, #[clap(short = 'o', long = "monitor")] monitor: Option, // todo support this @@ -477,24 +481,33 @@ impl Config { #[must_use] pub fn insensitive(&self) -> bool { - self.insensitive.unwrap_or(true) + self.insensitive } #[must_use] pub fn hide_search(&self) -> bool { self.hide_search.unwrap_or(false) } - + #[must_use] pub fn search(&self) -> Option { self.search.clone() } + + #[must_use] + pub fn allow_markup(&self) -> bool { + self.allow_markup.unwrap_or(false) + } } fn default_false() -> bool { false } +fn default_true() -> bool { + true +} + // // // TODO // // GtkOrientation orientation = config_get_mnemonic(config, "orientation", "vertical", 2, "vertical", "horizontal"); @@ -508,7 +521,6 @@ fn default_false() -> bool { // // GtkAlign valign = config_get_mnemonic(config, "valign", default_valign, 4, "fill", "start", "end", "center"); // // char* prompt = config_get(config, "prompt", mode); // // uint64_t filter_rate = strtol(config_get(config, "filter_rate", "100"), NULL, 10); -// // allow_images = strcmp(config_get(config, "allow_images", "false"), "true") == 0; // // allow_markup = strcmp(config_get(config, "allow_markup", "false"), "true") == 0; // // image_size = strtol(config_get(config, "image_size", "32"), NULL, 10); // // cache_file = map_get(config, "cache_file"); diff --git a/src/lib/gui.rs b/src/lib/gui.rs index b7a46b1..1a40c6e 100644 --- a/src/lib/gui.rs +++ b/src/lib/gui.rs @@ -801,6 +801,7 @@ fn create_menu_row( } let label = Label::new(Some(element_to_add.label.as_str())); + label.set_use_markup(meta.config.allow_markup()); label.set_natural_wrap_mode(meta.config.line_wrap().into()); label.set_hexpand(true);