diff --git a/src/ui/mod.rs b/src/ui/mod.rs index aa6f2c1..f334de8 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -669,6 +669,30 @@ impl<'ws> Workspace<'ws> { self.state.reset_n_prefix(); self.state.char_queue.clear(); } + KeyCode::Char('b') if key.modifiers.contains(KeyModifiers::CONTROL) => { + 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, + })?; + } + KeyCode::Char('i') if key.modifiers.contains(KeyModifiers::CONTROL) => { + let address = self.book.location.clone(); + self.book.set_cell_style( + &[("font.i", "true")], + &Area { + sheet: self.book.current_sheet, + row: address.row as i32, + column: address.col as i32, + width: 1, + height: 1, + })?; + } KeyCode::Char(d) if d.is_ascii_digit() => { self.handle_numeric_prefix(d); } @@ -831,18 +855,6 @@ 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 847c589..21cc249 100644 --- a/src/ui/test.rs +++ b/src/ui/test.rs @@ -1291,7 +1291,7 @@ fn test_bold_text() { .expect("Failed to get style"); assert!(!before_style.font.b); script() - .char('b') + .ctrl('b') .run(&mut ws) .expect("Unable to run script"); let style = ws @@ -1301,6 +1301,25 @@ fn test_bold_text() { assert!(style.font.b); } +#[test] +fn test_italic_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.i); + script() + .ctrl('i') + .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.i); +} + fn new_workspace<'a>() -> Workspace<'a> { Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook") }