Compare commits

...

2 Commits

Author SHA1 Message Date
c758f65a5c feat: s replaces a cells contents 2024-12-14 11:15:07 -05:00
142ecef24c chore: renames and other housekeeping 2024-12-14 08:09:20 -05:00
3 changed files with 10 additions and 5 deletions

View File

@ -5,7 +5,7 @@ use slice_utils::{Measured, Peekable, Seekable, Span, StrCursor};
#[derive(Debug, PartialEq, Eq)]
pub enum Cmd<'a> {
Write(Option<&'a str>),
InsertRow(usize),
InsertRows(usize),
InsertColumns(usize),
RenameSheet(Option<usize>, &'a str),
NewSheet(Option<&'a str>),
@ -155,7 +155,7 @@ fn try_consume_insert_row<'cmd, 'i: 'cmd>(
return Err("Invalid command: Did you mean to type `insert-rows <arg>`?");
}
let arg = input.span(0..).trim();
return Ok(Some(Cmd::InsertRow(if arg.is_empty() {
return Ok(Some(Cmd::InsertRows(if arg.is_empty() {
1
} else {
if let Ok(count) = arg.parse() {

View File

@ -425,7 +425,7 @@ impl<'ws> Workspace<'ws> {
self.book.evaluate();
Ok(None)
}
Ok(Some(Cmd::InsertRow(count))) => {
Ok(Some(Cmd::InsertRows(count))) => {
self.book.insert_rows(self.book.location.row, count)?;
self.book.evaluate();
Ok(None)
@ -657,6 +657,11 @@ impl<'ws> Workspace<'ws> {
KeyCode::Char('s') if key.modifiers == KeyModifiers::CONTROL => {
self.save_file()?;
}
KeyCode::Char('s') if key.modifiers != KeyModifiers::CONTROL => {
self.book.clear_current_cell()?;
self.text_area = reset_text_area(String::new());
self.enter_edit_mode();
}
KeyCode::Char('r') if key.modifiers == KeyModifiers::CONTROL => {
self.enter_range_select_mode();
}

View File

@ -35,7 +35,7 @@ fn test_insert_rows_cmd() {
let output = result.unwrap();
assert!(output.is_some());
let cmd = output.unwrap();
assert_eq!(cmd, Cmd::InsertRow(1));
assert_eq!(cmd, Cmd::InsertRows(1));
}
#[test]
@ -46,7 +46,7 @@ fn test_insert_rows_cmd_short() {
let output = result.unwrap();
assert!(output.is_some());
let cmd = output.unwrap();
assert_eq!(cmd, Cmd::InsertRow(1));
assert_eq!(cmd, Cmd::InsertRows(1));
}
#[test]