From c3f84b10ad05179dd3ae80fba3447aca10ec62cd Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Wed, 26 Feb 2025 18:10:23 -0500 Subject: [PATCH] wip: styling: bold text --- result | 0 src/book/mod.rs | 10 ---------- src/ui/mod.rs | 12 ++++++++++++ src/ui/test.rs | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 10 deletions(-) mode change 120000 => 100644 result diff --git a/result b/result deleted file mode 120000 index 774cfe9..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/mvnsm5ndvx4psah2d3y6yd2vwkypy9m7-sheetui-0.1.0 \ No newline at end of file diff --git a/result b/result new file mode 100644 index 0000000..774cfe9 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/mvnsm5ndvx4psah2d3y6yd2vwkypy9m7-sheetui-0.1.0 \ No newline at end of file diff --git a/src/book/mod.rs b/src/book/mod.rs index 6651a82..9f9225f 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -343,12 +343,6 @@ impl Book { sheet: u32, col_idx: usize, ) -> Result<()> { - // TODO(jeremy): This is a little hacky and the underlying model - // supports a better mechanism but UserModel doesn't support it yet. - // https://github.com/ironcalc/IronCalc/issues/273 - // https://github.com/ironcalc/IronCalc/pull/276 is the coming fix. - // NOTE(jwall): Because of the number of cells required to modify - // this is crazy slow let area = self.get_col_range(sheet, col_idx); self.set_cell_style(style, &area)?; Ok(()) @@ -373,10 +367,6 @@ impl Book { sheet: u32, row_idx: usize, ) -> Result<()> { - // TODO(jeremy): This is a little hacky and the underlying model - // supports a better mechanism but UserModel doesn't support it yet. - // https://github.com/ironcalc/IronCalc/issues/273 - // https://github.com/ironcalc/IronCalc/pull/276 is the coming fix. let area = self.get_row_range(sheet, row_idx); self.set_cell_style(style, &area)?; Ok(()) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 662426d..aa6f2c1 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -831,6 +831,18 @@ impl<'ws> Workspace<'ws> { self.state.char_queue.push('g'); } } + KeyCode::Char('b') => { + let address = self.book.location.clone(); + self.book.set_cell_style( + &[("font.b", "true")], + &Area { + sheet: self.book.current_sheet, + row: address.row as i32, + column: address.col as i32, + width: 1, + height: 1, + })?; + } _ => { // noop self.state.char_queue.clear(); diff --git a/src/ui/test.rs b/src/ui/test.rs index 356b695..0446e8a 100644 --- a/src/ui/test.rs +++ b/src/ui/test.rs @@ -1272,6 +1272,24 @@ fn test_color_col() { } } +#[test] +fn test_bold_text() { + let mut ws = new_workspace(); + let before_style = ws + .book + .get_cell_style(0, &Address { row: 1, col: 1 }) + .expect("Failed to get style"); + assert!(!before_style.font.b); + script() + .char('b') + .run(&mut ws) + .expect("Unable to run script"); + let style = ws + .book + .get_cell_style(0, &Address { row: 1, col: 1 }) + .expect("Failed to get style"); + assert!(style.font.b); +} fn new_workspace<'a>() -> Workspace<'a> { Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook")