summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-03-05 13:36:41 -0500
committerJesse Luehrs <doy@tozt.net>2022-03-05 13:36:41 -0500
commit9739d754e72d82248c93e7d54d9b7f0cac669c28 (patch)
tree819fb90c88edcb605e72c2fc9dcd9930e363d6b7
parente9e6883e7ffaee7cc0e10d00a251e364b069ef83 (diff)
downloadnbsh-9739d754e72d82248c93e7d54d9b7f0cac669c28.tar.gz
nbsh-9739d754e72d82248c93e7d54d9b7f0cac669c28.zip
simplify
-rw-r--r--src/shell/history/entry.rs8
-rw-r--r--src/shell/history/pty.rs28
2 files changed, 21 insertions, 15 deletions
diff --git a/src/shell/history/entry.rs b/src/shell/history/entry.rs
index 6cad678..ad931dc 100644
--- a/src/shell/history/entry.rs
+++ b/src/shell/history/entry.rs
@@ -63,7 +63,9 @@ impl Entry {
},
);
- vt.bell(out, focused);
+ if vt.bell(focused) {
+ out.write(b"\x07");
+ }
Self::set_bgcolor(out, idx, focused);
out.set_fgcolor(textmode::color::YELLOW);
@@ -206,7 +208,9 @@ impl Entry {
pub fn render_fullscreen(&self, out: &mut impl textmode::Textmode) {
self.pty.with_vt_mut(|vt| {
out.write(&vt.screen().state_formatted());
- vt.bell(out, true);
+ if vt.bell(true) {
+ out.write(b"\x07");
+ }
out.reset_attributes();
});
}
diff --git a/src/shell/history/pty.rs b/src/shell/history/pty.rs
index 49ec4c9..cef4ca9 100644
--- a/src/shell/history/pty.rs
+++ b/src/shell/history/pty.rs
@@ -116,8 +116,8 @@ impl Pty {
pub struct Vt {
vt: vt100::Parser,
- audible_bell_state: usize,
- audible_bell: bool,
+ bell_state: usize,
+ bell: bool,
real_bell_pending: bool,
}
@@ -125,8 +125,8 @@ impl Vt {
pub fn new(size: (u16, u16)) -> Self {
Self {
vt: vt100::Parser::new(size.0, size.1, 0),
- audible_bell_state: 0,
- audible_bell: false,
+ bell_state: 0,
+ bell: false,
real_bell_pending: false,
}
}
@@ -135,11 +135,11 @@ impl Vt {
self.vt.process(bytes);
let screen = self.vt.screen();
- let new_audible_bell_state = screen.audible_bell_count();
- if new_audible_bell_state != self.audible_bell_state {
- self.audible_bell = true;
+ let new_bell_state = screen.audible_bell_count();
+ if new_bell_state != self.bell_state {
+ self.bell = true;
self.real_bell_pending = true;
- self.audible_bell_state = new_audible_bell_state;
+ self.bell_state = new_bell_state;
}
}
@@ -152,19 +152,21 @@ impl Vt {
}
pub fn is_bell(&self) -> bool {
- self.audible_bell
+ self.bell
}
- pub fn bell(&mut self, out: &mut impl textmode::Textmode, focused: bool) {
+ pub fn bell(&mut self, focused: bool) -> bool {
+ let mut should = false;
if self.real_bell_pending {
- if self.audible_bell {
- out.write(b"\x07");
+ if self.bell {
+ should = true;
}
self.real_bell_pending = false;
}
if focused {
- self.audible_bell = false;
+ self.bell = false;
}
+ should
}
pub fn binary(&self) -> bool {