From 5fbff134289947b1d936d4314ff2fc74b7212dff Mon Sep 17 00:00:00 2001 From: Rushmore75 Date: Mon, 9 Feb 2026 13:24:09 -0700 Subject: [PATCH] close #6 --- src/app/app.rs | 7 ++++++- src/app/screen.rs | 20 +++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/app/app.rs b/src/app/app.rs index 0cd9b27..d090ecc 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -19,7 +19,7 @@ use crate::app::{ clipboard::Clipboard, error_msg::StatusMessage, logic::{ - calc::{Grid, get_header_size}, + calc::{Grid, LEN, get_header_size}, cell::CellType, }, mode::Mode, @@ -124,6 +124,11 @@ impl Widget for &App { y_idx = y as usize - 1 + self.screen.scroll_y(); } + // don't render non-accessible cells + if x_idx > LEN-1 { + continue; + } + const ORANGE1: Color = Color::Rgb(200, 160, 0); const ORANGE2: Color = Color::Rgb(180, 130, 0); diff --git a/src/app/screen.rs b/src/app/screen.rs index 23fce25..0e82aba 100644 --- a/src/app/screen.rs +++ b/src/app/screen.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, sync::RwLock}; +use std::{cmp::min, collections::HashMap, sync::RwLock}; use ratatui::prelude; @@ -123,22 +123,12 @@ impl ScreenSpace { l.1 = area.height as usize; } - // let width = (area.width as usize + calc::get_header_size() -1) / self.get_cell_width(vars); - let width = area.width as usize / self.get_cell_width(vars); + let width = (area.width as usize / self.get_cell_width(vars)) + 1; let height = area.height as usize / self.get_cell_height(vars); - let x_max = - if width > LEN { - LEN - 1 - } else { - width - }; - let y_max = - if height > LEN { - LEN - 1 - } else { - height - }; + let x_max = min(LEN-1, width); + let y_max = min(LEN-1, height); + (x_max as u16, y_max as u16) }