diff --git a/docs/index.md b/docs/index.md index c317fa9..df8d3e2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,10 +7,10 @@ Currently this will print out: ```sh -Usage: sheetui [OPTIONS] +Usage: sheetui [OPTIONS] [WORKBOOK] Arguments: - + [WORKBOOK] Options: -l, --locale-name [default: en] @@ -20,6 +20,8 @@ Options: -V, --version Print version ``` +If you do not provide a workbook path, sheetui will open an empty workbook. + ## Supported formats Currently we only support the [ironcalc](https://docs.ironcalc.com/) xlsx diff --git a/docs/navigation.md b/docs/navigation.md index dff745e..a9e3f06 100644 --- a/docs/navigation.md +++ b/docs/navigation.md @@ -32,6 +32,8 @@ will clear the numeric prefix if you want to cancel it. * 'I' will toggle italic on the cell. 'B' will toggle bold. * `Ctrl-h` will shorten the width of the column you are on. * `Ctrl-l` will lengthen the width of the column you are on. +* `o` will insert a row below the selected cell, move one cell down, and enter edit mode +* `O` will insert a row above the selected cell, move one cell up, and enter edit mode ## Other Keybindings diff --git a/src/main.rs b/src/main.rs index cd6b9ac..a80d330 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ mod ui; #[command(version, about, long_about = None)] pub struct Args { #[arg()] - workbook: PathBuf, + workbook: Option, #[arg(default_value_t=String::from("en"), short, long)] locale_name: String, #[arg(default_value_t=String::from("America/New_York"), short, long)] @@ -27,7 +27,11 @@ pub struct Args { type ReadFn = Box anyhow::Result>; fn run(terminal: &mut ratatui::DefaultTerminal, args: Args) -> anyhow::Result { - let mut ws = Workspace::load(&args.workbook, &args.locale_name, &args.timezone_name)?; + let mut ws = if let Some(workbook_path) = &args.workbook { + Workspace::load(workbook_path, &args.locale_name, &args.timezone_name)? + } else { + Workspace::new_empty(&args.locale_name, &args.timezone_name)? + }; let mut read_func: ReadFn = if let Some(log_path) = args.log_input { { let log_file = std::fs::File::create(log_path)?; diff --git a/src/ui/mod.rs b/src/ui/mod.rs index d0bd2c0..47d8268 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -881,6 +881,18 @@ impl<'ws> Workspace<'ws> { self.state.char_queue.push('g'); } } + KeyCode::Char('o') => { + self.book.insert_rows(self.book.location.row+1, 1)?; + self.move_down()?; + self.handle_movement_change(); + self.enter_edit_mode(); + }, + KeyCode::Char('O') => { + self.book.insert_rows(self.book.location.row, 1)?; + self.move_up()?; + self.handle_movement_change(); + self.enter_edit_mode(); + }, _ => { // noop self.state.char_queue.clear();