Merge remote-tracking branch 'gh/main' into feat/cgqt-import-collision-step

# Conflicts:
#	context/test-evidence/tui.md
This commit is contained in:
Edward Langley
2026-09-24 18:43:40 -07:00
6 changed files with 278 additions and 51 deletions
+15 -2
View File
@@ -23,7 +23,9 @@ use crate::model::cell::{CellKey, CellValue, DataStore};
use crate::persistence;
use crate::ui::effect::{EffectKind, ModelChange, ViewTarget};
use crate::ui::project::Dirty;
use crate::ui::viewport::{compute_col_widths, compute_row_header_width, compute_visible_cols};
use crate::ui::viewport::{
compute_col_widths, compute_row_header_width, compute_visible_cols, grid_width,
};
use crate::view::{GridLayout, View};
use crate::workbook::Workbook;
use improvise_core::model::record::{AggregateHash, RecordHash};
@@ -556,6 +558,17 @@ impl App {
app
}
/// Whether any of the three side panels has taken its column.
pub fn side_panel_open(&self) -> bool {
let vs = &self.view_state;
vs.formula_panel_open || vs.category_panel_open || vs.view_panel_open
}
/// The terminal columns the grid gets (improvise-gtn7.1).
pub fn grid_width(&self) -> u16 {
grid_width(self.term_width, self.side_panel_open())
}
/// This client's cursor in the active view. Absent means the origin, so
/// a view visited for the first time opens at (0, 0).
pub fn cursor(&self) -> ViewCursor {
@@ -961,7 +974,7 @@ impl App {
compute_visible_cols(
&col_widths,
row_header_width,
self.term_width,
self.grid_width(),
cursor.col_offset,
)
},
+17 -2
View File
@@ -161,15 +161,30 @@ pub fn compute_row_header_width(layout: &GridLayout) -> u16 {
.sum()
}
/// The TUI's side-panel column, and the least the grid keeps beside it.
pub const SIDE_PANEL_WIDTH: u16 = 32;
pub const MIN_GRID_WIDTH: u16 = 40;
/// The grid's width once any side panel has its column: the one answer the
/// keypress path and the frame layout share (`context/code/tui.md`).
pub fn grid_width(term_width: u16, side_panel_open: bool) -> u16 {
match side_panel_open {
true => term_width
.saturating_sub(SIDE_PANEL_WIDTH)
.max(MIN_GRID_WIDTH.min(term_width)),
false => term_width,
}
}
/// Count how many columns fit starting from `col_offset` given the available width.
pub fn compute_visible_cols(
col_widths: &[u16],
row_header_width: u16,
term_width: u16,
grid_width: u16,
col_offset: usize,
) -> usize {
// Account for grid border (2 chars)
let data_area_width = term_width
let data_area_width = grid_width
.saturating_sub(2)
.saturating_sub(row_header_width);
let mut acc = 0u16;