Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement passing the bell signal to the terminal #981

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}