wip: styling: bold text

This commit is contained in:
Jeremy Wall 2025-02-26 18:10:23 -05:00
parent b5e0362a4e
commit c3f84b10ad
4 changed files with 30 additions and 10 deletions

1
result
View File

@ -1 +0,0 @@
/nix/store/mvnsm5ndvx4psah2d3y6yd2vwkypy9m7-sheetui-0.1.0

1
result Normal file
View File

@ -0,0 +1 @@
/nix/store/mvnsm5ndvx4psah2d3y6yd2vwkypy9m7-sheetui-0.1.0

View File

@ -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(())

View File

@ -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();

View File

@ -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")