line editor now sends bell on no-op edits

This commit is contained in:
2026-02-20 14:15:25 -05:00
parent 5721cdb7ca
commit 6f334395f7
2 changed files with 25 additions and 6 deletions

View File

@@ -18,8 +18,7 @@ use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
use vte::{Parser, Perform};
use crate::{
libsh::{error::{ShErr, ShErrKind, ShResult}, sys::TTY_FILENO},
prompt::readline::keys::{KeyCode, ModKeys},
libsh::{error::{ShErr, ShErrKind, ShResult}, sys::TTY_FILENO}, prompt::readline::keys::{KeyCode, ModKeys}, shopt::FernBellStyle, state::read_shopts
};
use crate::{
prelude::*,
@@ -185,6 +184,7 @@ pub trait LineWriter {
fn clear_rows(&mut self, layout: &Layout) -> ShResult<()>;
fn redraw(&mut self, prompt: &str, line: &str, new_layout: &Layout) -> ShResult<()>;
fn flush_write(&mut self, buf: &str) -> ShResult<()>;
fn send_bell(&mut self) -> ShResult<()>;
}
#[derive(Clone, Copy, Debug)]
@@ -975,4 +975,18 @@ impl LineWriter for TermWriter {
write_all(self.out, buf)?;
Ok(())
}
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 */ }
}
Ok(())
}
}