-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I noticed during some testing that if a panic (via panic!, todo!, etc) occurred, inside a running Controller, then mouse inputs are being read by the terminal after the controller exits. While a panic is obviously not expected behaviour, having a side effect that renders a terminal unusable on most/all modern computers is undesirable.
MVE:
use termgame::{SimpleEvent, Controller, Game, GameEvent, GameSettings, StyledCharacter, run_game, KeyCode};
use std::error::Error;
use std::time::Duration;
struct MyGame {}
impl Controller for MyGame {
fn on_start(&mut self, game: &mut Game) {
}
fn on_event(&mut self, game: &mut Game, event: GameEvent) {
match event.into() {
SimpleEvent::Just(KeyCode::Char(ch)) => {
game.set_screen_char(1, 1, Some(StyledCharacter::new(ch)))
},
_ => {}
}
}
fn on_tick(&mut self, _game: &mut Game) { panic!("This shouldn't break terminals!") }
}
fn main() -> Result<(), Box<dyn Error>> {
let mut controller = MyGame {};
run_game(
&mut controller,
GameSettings::new()
// The below are the defaults, but shown so you can edit them.
.tick_duration(Duration::from_millis(50))
.quit_event(Some(SimpleEvent::WithControl(KeyCode::Char('c')).into()))
)?;
println!("Game Ended!");
Ok(())
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels