Skip to content

Commit

Permalink
Implement passing the bell signal to the terminal (#981)
Browse files Browse the repository at this point in the history
* implement passing the bell signal to the terminal

* Add files via upload

add fixture to test against
  • Loading branch information
auronandace committed Jan 3, 2022
1 parent 82384dc commit 00e923c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tests/fixtures/ring_bell
Original file line number Diff line number Diff line change
@@ -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
❯
Expand Down
5 changes: 5 additions & 0 deletions zellij-server/src/panes/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -446,6 +447,7 @@ impl Grid {
changed_colors: None,
is_scrolled: false,
link_handler: Default::default(),
ring_bell: false,
scrollback_buffer_lines: 0,
}
}
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions zellij-server/src/panes/terminal_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions zellij-server/src/panes/unit/grid_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 00e923c

Please sign in to comment.