diff --git a/src/main.rs b/src/main.rs index 4daca28..1ef39ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,22 @@ fn main() -> Result<()> { let mut area = frame.size(); frame.render_widget(Block::default().style(Style::default().bg(Color::Green)), area); + // don't draw stuff except an info box if the terminal is too small (less than 80x25) + // to prevent the read drawing code from crashing the game. + if area.width < 80 || area.height < 25 { + let block = Block::default() + .title("Info") + .borders(Borders::ALL) + .border_style(Style::default().fg(Color::White)) + .border_type(BorderType::Rounded) + .style(Style::default().bg(Color::Black)); + let paragraph = Paragraph::new("Terminal needs to be at leas 80x25!") + .block(block) + .wrap(Wrap { trim: true }); + frame.render_widget(paragraph, area); + return + } + if area.width > 80 { area.x = (area.width - 80) / 2; area.width = 80;