From 34b780c64402a23a9d8fe9279afeb1122bc1bd2a Mon Sep 17 00:00:00 2001 From: pagedmov Date: Mon, 23 Feb 2026 14:06:10 -0500 Subject: [PATCH] changed bell style option to a simple boolean --- nix/hm-module.nix | 10 +++++----- src/prompt/readline/mod.rs | 7 ++----- src/prompt/readline/term.rs | 10 ++-------- src/shopt.rs | 24 +++++++----------------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 96943eb..2a42a72 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -58,10 +58,10 @@ in default = true; description = "Whether to automatically add commands to the history as they are executed"; }; - bellStyle = lib.mkOption { - type = lib.types.enum [ "none" "audible" "visible" ]; - default = "audible"; - description = "The style of bell to use for notifications and errors"; + bellEnabled = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to allow fern to ring the terminal bell on certain events (e.g. command completion, errors, etc.)"; }; maxRecurseDepth = lib.mkOption { type = lib.types.int; @@ -117,7 +117,7 @@ in "shopt core.max_hist=${toString cfg.settings.maxHistoryEntries}" "shopt core.interactive_comments=${boolToString cfg.settings.interactiveComments}" "shopt core.auto_hist=${boolToString cfg.settings.autoHistory}" - "shopt core.bell_style=${cfg.settings.bellStyle}" + "shopt core.bell_enabled=${boolToString cfg.settings.bellEnabled}" "shopt core.max_recurse_depth=${toString cfg.settings.maxRecurseDepth}" "shopt prompt.trunc_prompt_path=${toString cfg.settings.promptPathSegments}" diff --git a/src/prompt/readline/mod.rs b/src/prompt/readline/mod.rs index f823662..6952f58 100644 --- a/src/prompt/readline/mod.rs +++ b/src/prompt/readline/mod.rs @@ -223,11 +223,8 @@ impl FernVi { let hint = self.history.get_hint(); self.editor.set_hint(hint); } - None => match read_shopts(|s| s.core.bell_style) { - crate::shopt::FernBellStyle::Audible => { - self.writer.send_bell().ok(); - } - crate::shopt::FernBellStyle::Visible | crate::shopt::FernBellStyle::Disable => {} + None => { + self.writer.send_bell().ok(); }, } diff --git a/src/prompt/readline/term.rs b/src/prompt/readline/term.rs index eb63886..118fc3b 100644 --- a/src/prompt/readline/term.rs +++ b/src/prompt/readline/term.rs @@ -977,14 +977,8 @@ impl LineWriter for TermWriter { } fn send_bell(&mut self) -> ShResult<()> { - match read_shopts(|o| o.core.bell_style) { - FernBellStyle::Audible => { - self.flush_write("\x07")?; - } - FernBellStyle::Visible => { - log::warn!("Visual bell is not supported in fern shell yet"); - } - FernBellStyle::Disable => { /* Do nothing */ } + if read_shopts(|o| o.core.bell_enabled) { + self.flush_write("\x07")?; } Ok(()) } diff --git a/src/shopt.rs b/src/shopt.rs index 704df86..49a8032 100644 --- a/src/shopt.rs +++ b/src/shopt.rs @@ -27,16 +27,6 @@ impl FromStr for FernBellStyle { } } -impl Display for FernBellStyle { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - FernBellStyle::Audible => write!(f, "audible"), - FernBellStyle::Visible => write!(f, "visible"), - FernBellStyle::Disable => write!(f, "disable"), - } - } -} - #[derive(Default, Clone, Copy, Debug)] pub enum FernEditMode { #[default] @@ -159,7 +149,7 @@ pub struct ShOptCore { pub max_hist: usize, pub interactive_comments: bool, pub auto_hist: bool, - pub bell_style: FernBellStyle, + pub bell_enabled: bool, pub max_recurse_depth: usize, } @@ -221,7 +211,7 @@ impl ShOptCore { self.auto_hist = val; } "bell_style" => { - let Ok(val) = val.parse::() else { + let Ok(val) = val.parse::() else { return Err( ShErr::simple( ShErrKind::SyntaxErr, @@ -233,7 +223,7 @@ impl ShOptCore { ), ); }; - self.bell_style = val; + self.bell_enabled = val; } "max_recurse_depth" => { let Ok(val) = val.parse::() else { @@ -311,8 +301,8 @@ impl ShOptCore { Ok(Some(output)) } "bell_style" => { - let mut output = String::from("What type of bell style to use for the bell character\n"); - output.push_str(&format!("{}", self.bell_style)); + let mut output = String::from("Whether or not to allow fern to trigger the terminal bell"); + output.push_str(&format!("{}", self.bell_enabled)); Ok(Some(output)) } "max_recurse_depth" => { @@ -355,7 +345,7 @@ impl Display for ShOptCore { self.interactive_comments )); output.push(format!("auto_hist = {}", self.auto_hist)); - output.push(format!("bell_style = {}", self.bell_style)); + output.push(format!("bell_enabled = {}", self.bell_enabled)); output.push(format!("max_recurse_depth = {}", self.max_recurse_depth)); let final_output = output.join("\n"); @@ -373,7 +363,7 @@ impl Default for ShOptCore { max_hist: 1000, interactive_comments: true, auto_hist: true, - bell_style: FernBellStyle::Audible, + bell_enabled: true, max_recurse_depth: 1000, } }