Implement passing the bell signal to the terminal (#981)

* implement passing the bell signal to the terminal

* Add files via upload

add fixture to test against
This commit is contained in:
auronandace 2022-01-03 14:50:00 +00:00 committed by GitHub
parent 82384dc970
commit 00e923cfdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 0 deletions

6
src/tests/fixtures/ring_bell vendored Normal file
View file

@ -0,0 +1,6 @@
[?2004h
zellij on  main [!] is 📦 v0.24.0 via 🦀 v1.57.0 
  bell
[?2004l [?2004h
zellij on  main [!] is 📦 v0.24.0 via 🦀 v1.57.0 took 5s


View file

@ -399,6 +399,7 @@ pub struct Grid {
pub title: Option<String>,
pub is_scrolled: bool,
pub link_handler: LinkHandler,
pub ring_bell: bool,
scrollback_buffer_lines: usize,
}
@ -446,6 +447,7 @@ impl Grid {
changed_colors: None,
is_scrolled: false,
link_handler: Default::default(),
ring_bell: false,
scrollback_buffer_lines: 0,
}
}
@ -1506,6 +1508,9 @@ impl Perform for Grid {
fn execute(&mut self, byte: u8) {
match byte {
7 => {
self.ring_bell = true;
}
8 => {
// backspace
self.move_cursor_back(1);

View file

@ -273,6 +273,11 @@ impl Pane for TerminalPane {
}
character_styles.clear();
}
if self.grid.ring_bell {
let ring_bell = '\u{7}';
vte_output.push(ring_bell);
self.grid.ring_bell = false;
}
self.set_should_render(false);
Some(vte_output)
} else {

View file

@ -1078,3 +1078,15 @@ pub fn full_screen_scroll_region_and_scroll_up() {
grid.scroll_up_one_line();
assert_snapshot!(format!("{:?}", grid));
}
#[test]
pub fn ring_bell() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(134, 64, Palette::default());
let fixture_name = "ring_bell";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert!(grid.ring_bell);
}