Print bell character
This commit is contained in:
parent
96b2e13c4a
commit
89b4595ed9
3 changed files with 18 additions and 1 deletions
|
|
@ -13,6 +13,9 @@ Procedure when bumping the version number:
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- `Frame::set_bell` to print a bell character when the frame is displayed
|
||||
|
||||
## v0.3.3 - 2025-02-28
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ pub struct Frame {
|
|||
pub(crate) widthdb: WidthDb,
|
||||
pub(crate) buffer: Buffer,
|
||||
pub(crate) title: Option<String>,
|
||||
pub(crate) bell: bool,
|
||||
}
|
||||
|
||||
impl Frame {
|
||||
|
|
@ -48,6 +49,10 @@ impl Frame {
|
|||
self.title = title;
|
||||
}
|
||||
|
||||
pub fn set_bell(&mut self, bell: bool) {
|
||||
self.bell = bell;
|
||||
}
|
||||
|
||||
pub fn widthdb(&mut self) -> &mut WidthDb {
|
||||
&mut self.widthdb
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crossterm::event::{
|
|||
DisableBracketedPaste, EnableBracketedPaste, KeyboardEnhancementFlags,
|
||||
PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
||||
};
|
||||
use crossterm::style::{PrintStyledContent, StyledContent};
|
||||
use crossterm::style::{Print, PrintStyledContent, StyledContent};
|
||||
use crossterm::terminal::{
|
||||
BeginSynchronizedUpdate, Clear, ClearType, EndSynchronizedUpdate, EnterAlternateScreen,
|
||||
LeaveAlternateScreen, SetTitle,
|
||||
|
|
@ -274,6 +274,7 @@ impl Terminal {
|
|||
self.draw_differences()?;
|
||||
self.update_cursor()?;
|
||||
self.update_title()?;
|
||||
self.ring_bell()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -315,4 +316,12 @@ impl Terminal {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ring_bell(&mut self) -> io::Result<()> {
|
||||
if self.frame.bell {
|
||||
self.out.queue(Print('\x07'))?;
|
||||
}
|
||||
self.frame.bell = false;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue