test: use gpt-oss-20b to do some minor refactoring

This commit is contained in:
Edward Langley
2026-03-31 22:50:07 -07:00
parent bbfd2dc163
commit bbd1f48b78
2 changed files with 28 additions and 14 deletions

View File

@ -26,6 +26,11 @@ use ratatui::{
use model::Model; use model::Model;
use ui::app::{App, AppMode}; use ui::app::{App, AppMode};
fn render_paragraph(f: &mut Frame, area: Rect, text: &str, style: Style) {
f.render_widget(Paragraph::new(text).style(style), area);
}
use ui::category_panel::CategoryPanel; use ui::category_panel::CategoryPanel;
use ui::formula_panel::FormulaPanel; use ui::formula_panel::FormulaPanel;
use ui::grid::GridWidget; use ui::grid::GridWidget;
@ -332,14 +337,14 @@ fn draw_title(f: &mut Frame, area: Rect, app: &App) {
let right = " ?:help :q quit "; let right = " ?:help :q quit ";
let pad = " ".repeat((area.width as usize).saturating_sub(title.len() + right.len())); let pad = " ".repeat((area.width as usize).saturating_sub(title.len() + right.len()));
let line = format!("{title}{pad}{right}"); let line = format!("{title}{pad}{right}");
f.render_widget( render_paragraph(
Paragraph::new(line).style( f,
area,
&line,
Style::default() Style::default()
.fg(Color::Black) .fg(Color::Black)
.bg(Color::Blue) .bg(Color::Blue)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
),
area,
); );
} }
@ -450,7 +455,7 @@ fn draw_status(f: &mut Frame, area: Rect, app: &App) {
_ => Style::default().fg(Color::Black).bg(Color::DarkGray), _ => Style::default().fg(Color::Black).bg(Color::DarkGray),
}; };
f.render_widget(Paragraph::new(line).style(badge_style), area); render_paragraph(f, area, &line, badge_style);
} }
fn draw_command_bar(f: &mut Frame, area: Rect, app: &App) { fn draw_command_bar(f: &mut Frame, area: Rect, app: &App) {
@ -460,9 +465,11 @@ fn draw_command_bar(f: &mut Frame, area: Rect, app: &App) {
"" ""
}; };
let line = format!(":{buf}"); let line = format!(":{buf}");
f.render_widget( render_paragraph(
Paragraph::new(line).style(Style::default().fg(Color::White).bg(Color::Black)), f,
area, area,
&line,
Style::default().fg(Color::White).bg(Color::Black),
); );
} }
@ -484,9 +491,11 @@ fn draw_export_prompt(f: &mut Frame, area: Rect, app: &App) {
.title(" Export CSV — path (Esc cancel) "); .title(" Export CSV — path (Esc cancel) ");
let inner = block.inner(popup_area); let inner = block.inner(popup_area);
f.render_widget(block, popup_area); f.render_widget(block, popup_area);
f.render_widget( render_paragraph(
Paragraph::new(format!("{buf}")).style(Style::default().fg(Color::Green)), f,
inner, inner,
&format!("{buf}"),
Style::default().fg(Color::Green),
); );
} }

View File

@ -291,7 +291,7 @@ impl<'a> GridWidget<'a> {
}; };
let value = self.model.evaluate(&key); let value = self.model.evaluate(&key);
let cell_str = format_value(value.as_ref(), fmt_comma, fmt_decimals); let cell_str = format_cell_value(value.as_ref(), &view.number_format);
let is_selected = ri == sel_row && ci == sel_col; let is_selected = ri == sel_row && ci == sel_col;
let is_search_match = !self.search_query.is_empty() let is_search_match = !self.search_query.is_empty()
&& cell_str && cell_str
@ -435,7 +435,7 @@ impl<'a> Widget for GridWidget<'a> {
} }
} }
fn format_value(v: Option<&CellValue>, comma: bool, decimals: u8) -> String { pub fn format_value(v: Option<&CellValue>, comma: bool, decimals: u8) -> String {
match v { match v {
Some(CellValue::Number(n)) => format_f64(*n, comma, decimals), Some(CellValue::Number(n)) => format_f64(*n, comma, decimals),
Some(CellValue::Text(s)) => s.clone(), Some(CellValue::Text(s)) => s.clone(),
@ -443,6 +443,11 @@ fn format_value(v: Option<&CellValue>, comma: bool, decimals: u8) -> String {
} }
} }
fn format_cell_value(v: Option<&CellValue>, fmt: &str) -> String {
let (comma, decimals) = parse_number_format(fmt);
format_value(v, comma, decimals)
}
pub fn parse_number_format(fmt: &str) -> (bool, u8) { pub fn parse_number_format(fmt: &str) -> (bool, u8) {
let comma = fmt.contains(','); let comma = fmt.contains(',');
let decimals = fmt let decimals = fmt