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
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `Frame::set_bell` to print a bell character when the frame is displayed
|
||||||
|
|
||||||
## v0.3.3 - 2025-02-28
|
## v0.3.3 - 2025-02-28
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ pub struct Frame {
|
||||||
pub(crate) widthdb: WidthDb,
|
pub(crate) widthdb: WidthDb,
|
||||||
pub(crate) buffer: Buffer,
|
pub(crate) buffer: Buffer,
|
||||||
pub(crate) title: Option<String>,
|
pub(crate) title: Option<String>,
|
||||||
|
pub(crate) bell: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Frame {
|
impl Frame {
|
||||||
|
|
@ -48,6 +49,10 @@ impl Frame {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_bell(&mut self, bell: bool) {
|
||||||
|
self.bell = bell;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn widthdb(&mut self) -> &mut WidthDb {
|
pub fn widthdb(&mut self) -> &mut WidthDb {
|
||||||
&mut self.widthdb
|
&mut self.widthdb
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crossterm::event::{
|
||||||
DisableBracketedPaste, EnableBracketedPaste, KeyboardEnhancementFlags,
|
DisableBracketedPaste, EnableBracketedPaste, KeyboardEnhancementFlags,
|
||||||
PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
||||||
};
|
};
|
||||||
use crossterm::style::{PrintStyledContent, StyledContent};
|
use crossterm::style::{Print, PrintStyledContent, StyledContent};
|
||||||
use crossterm::terminal::{
|
use crossterm::terminal::{
|
||||||
BeginSynchronizedUpdate, Clear, ClearType, EndSynchronizedUpdate, EnterAlternateScreen,
|
BeginSynchronizedUpdate, Clear, ClearType, EndSynchronizedUpdate, EnterAlternateScreen,
|
||||||
LeaveAlternateScreen, SetTitle,
|
LeaveAlternateScreen, SetTitle,
|
||||||
|
|
@ -274,6 +274,7 @@ impl Terminal {
|
||||||
self.draw_differences()?;
|
self.draw_differences()?;
|
||||||
self.update_cursor()?;
|
self.update_cursor()?;
|
||||||
self.update_title()?;
|
self.update_title()?;
|
||||||
|
self.ring_bell()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -315,4 +316,12 @@ impl Terminal {
|
||||||
}
|
}
|
||||||
Ok(())
|
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