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

Refactor various components of Rust code #490

Merged
merged 10 commits into from
Sep 19, 2024
11 changes: 6 additions & 5 deletions tui/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use ratatui::{
Frame,
};

const MIN_WIDTH: u16 = 77;
const MIN_HEIGHT: u16 = 19;

pub struct AppState {
/// Selected theme
theme: Theme,
Expand Down Expand Up @@ -68,16 +71,14 @@ impl AppState {
}
pub fn draw(&mut self, frame: &mut Frame) {
let terminal_size = frame.area();
let min_width = 77; // Minimum width threshold
let min_height = 19; // Minimum height threshold
lj3954 marked this conversation as resolved.
Show resolved Hide resolved

if terminal_size.width < min_width || terminal_size.height < min_height {
if terminal_size.width < MIN_WIDTH || terminal_size.height < MIN_HEIGHT {
let size_warning_message = format!(
"Terminal size too small:\nWidth = {} Height = {}\n\nMinimum size:\nWidth = {} Height = {}",
terminal_size.width,
terminal_size.height,
min_width,
min_height,
MIN_WIDTH,
MIN_HEIGHT,
);

let warning_paragraph = Paragraph::new(size_warning_message.clone())
Expand Down