From 7b551afe819c48e9ab645c0fd15bccec538aa064 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 Dec 2024 16:29:01 -0500 Subject: [PATCH 1/6] docs: First pass at a user manual progress on #10 --- docs/index.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/ui/mod.rs | 20 ------------- 2 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 docs/index.md diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..1c6f1d3 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,82 @@ +# The sheetui user documentation + +## Running sheetui + +`sheetui --help` will print out help for the command line tags. + +`sheetui path/to/file` will open the file as a spreadsheet. The file does not have to exist already. If it does not it will be created when you save the spreadsheet. + +## User Interface + +The sheetui user interface is loosely inspired by vim. It is a modal interface that is entirely keyboard driven. At nearly any time you can type `Alt-h` to get some context sensitive help. + +### Navigation Mode + +The interface will start out in navigation mode. You can navigate around the table and between the sheets using the following keybinds: + +**Cell Navigation** + +* `h`, ⬆️, and `TAB` will move one cell to the left. +* `l`, ➡️, and `Shift-Tab` will move one cell to the right. +* `j`, ⬇️, and `Enter` will move one cell down. +* `k`, ⬆️, and `Shift-Enter` will move one cell up. + +**Sheet Navigation** + +* `Ctrl-n` moves to the next sheet +* `Ctrl-p` moves to the prev sheet + +Sheet navigation moves loops around when it hits the end or beginning sheets. + +**Numeric prefixes** + +You can prefix each of the keybinds above with a numeric prefix to do them that many times. So `typing 123h` will move to the left 123 times. Hitting `Esc` will clear the numeric prefix if you want to cancel it. + +**Modifying the Sheet or Cells** + +* `e` or `i` will enter CellEdit mode for the current cell. +* `Ctrl-h` will shorten the width of the column you are on. +* `Ctrl-l` will lengthen the width of the column you are on. + +**Other Keybindings** + +* `Ctrl-s` will save the sheet. +* `q` will exit the application. +* `:` will enter CommandMode. + + + +### CellEdit Mode + +You enter CellEdit mode by hitting `e` or `i` while in navigation mode. Type what you want into the cell. + +Starting with: + +* `=` will treat what you type as a formula. +* `$` will treat it as us currency. + +Typing a number will treat the contents as a number. While typing non-numeric text will treat it as text content. + +For the most part this should work the same way you expect a spreadsheet to work. + +* `Enter` will update the cell contents. +* `Esc` will cancel editing the cell and leave it unedited. + + + +### Command Mode + +You enter command mode by typing `:` while in navigation mode. You can then type a command and hit `Enter` to execute it or `Esc` to cancel. + +The currently supported commands are: + +* `write [path]` save the current spreadsheet. If the path is provided it will save it to that path. If omitted it will save to the path you are currently editing. +* `insert-row [number]` Inserts a row into the sheet at your current row. If the number is provided then inserts that many rows. If omitted then just inserts one. +* `insert-column [number]` Just line `insert-row` but for columns. +* `rename-sheet [idx] ` rename a sheet. If the idx is provide then renames that sheet. If omitted then it renames the current sheet. +* `new-sheet [name]` Creates a new sheet. If the name is provided then uses that. If omitted then uses a default sheet name. +* `select-sheet ` Select a sheet by name. +* `edit ` Edit a new spreadsheet at the current path. +* `quit` Quits the application + + diff --git a/src/ui/mod.rs b/src/ui/mod.rs index cd7eaf6..3124b94 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -420,26 +420,6 @@ impl<'ws> Workspace<'ws> { Ok(()) })?; } - KeyCode::Char('r') if key.modifiers == KeyModifiers::CONTROL => { - self.run_with_prefix(|ws: &mut Workspace<'_>| -> Result<()> { - let (row_count, _) = ws.book.get_size()?; - ws.book.update_entry( - &Address { - row: row_count + 1, - col: 1, - }, - "", - )?; - let (row, _) = ws.book.get_size()?; - let mut loc = ws.book.location.clone(); - if loc.row < row as usize { - loc.row = row as usize; - ws.book.move_to(&loc)?; - } - ws.handle_movement_change(); - Ok(()) - })?; - } KeyCode::Char('q') => { return Ok(Some(ExitCode::SUCCESS)); } From 8ca1d2c103cdba3b7cadf12a0d4b5dbf101339f8 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 Dec 2024 17:21:20 -0500 Subject: [PATCH 2/6] docs: add links to ironcalc documentation progress on #10 --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 1c6f1d3..45dbdf0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -62,7 +62,7 @@ For the most part this should work the same way you expect a spreadsheet to work * `Enter` will update the cell contents. * `Esc` will cancel editing the cell and leave it unedited. - +You can find the functions we support documented here: [ironcalc docs](https://docs.ironcalc.com/functions/lookup-and-reference.html) ### Command Mode From 7abe186a33bfe9e491e2413eb53711ee75c89a12 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 Dec 2024 17:25:01 -0500 Subject: [PATCH 3/6] docs: add cli help output progress on #10 --- docs/index.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 45dbdf0..bc294d9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,21 @@ `sheetui --help` will print out help for the command line tags. -`sheetui path/to/file` will open the file as a spreadsheet. The file does not have to exist already. If it does not it will be created when you save the spreadsheet. +Currently this will print out: + +```sh +Usage: sheetui [OPTIONS] + +Arguments: + + +Options: + -l, --locale-name [default: en] + -t, --timezone-name [default: America/New_York] + --log-input + -h, --help Print help + -V, --version Print version +``` ## User Interface From 47614de9dd062152db7aa07082b5534e9c229d37 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 Dec 2024 17:31:40 -0500 Subject: [PATCH 4/6] docs: add link to the documentation in readme progress toward #10 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index bb726c5..e30eb05 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,7 @@ sheetui path/to/file.xlsx # edit/view a spreadsheet ``` + +## Reference + +* [Documentation](./docs/index.md) From 8af5212e5c7219c10a08bbcfc0b28492cd7e40c3 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 Dec 2024 17:37:09 -0500 Subject: [PATCH 5/6] docs: cleanup some non-prime-time stuff progress toward #10 --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index bc294d9..53d4117 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,9 +31,9 @@ The interface will start out in navigation mode. You can navigate around the tab **Cell Navigation** * `h`, ⬆️, and `TAB` will move one cell to the left. -* `l`, ➡️, and `Shift-Tab` will move one cell to the right. +* `l` and, ➡️ will move one cell to the right. * `j`, ⬇️, and `Enter` will move one cell down. -* `k`, ⬆️, and `Shift-Enter` will move one cell up. +* `k` ⬆️, will move one cell up. **Sheet Navigation** From 753874687c334cfd1e422b3cb03133f1e2b31f92 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 3 Dec 2024 17:43:30 -0500 Subject: [PATCH 6/6] docs: cleanup command docs and error reporting progress toward #10 --- docs/index.md | 16 ++++++++-------- src/ui/cmd.rs | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/index.md b/docs/index.md index 53d4117..7638535 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,11 +40,11 @@ The interface will start out in navigation mode. You can navigate around the tab * `Ctrl-n` moves to the next sheet * `Ctrl-p` moves to the prev sheet -Sheet navigation moves loops around when it hits the end or beginning sheets. +Sheet navigation moving will loop around when you reach the ends. **Numeric prefixes** -You can prefix each of the keybinds above with a numeric prefix to do them that many times. So `typing 123h` will move to the left 123 times. Hitting `Esc` will clear the numeric prefix if you want to cancel it. +You can prefix each of the keybinds above with a numeric prefix to do them that many times. So typing `123h` will move to the left 123 times. Hitting `Esc` will clear the numeric prefix if you want to cancel it. **Modifying the Sheet or Cells** @@ -84,13 +84,13 @@ You enter command mode by typing `:` while in navigation mode. You can then type The currently supported commands are: -* `write [path]` save the current spreadsheet. If the path is provided it will save it to that path. If omitted it will save to the path you are currently editing. -* `insert-row [number]` Inserts a row into the sheet at your current row. If the number is provided then inserts that many rows. If omitted then just inserts one. -* `insert-column [number]` Just line `insert-row` but for columns. +* `write [path]` save the current spreadsheet. If the path is provided it will save it to that path. If omitted it will save to the path you are currently editing. `w` is a shorthand alias for this command. +* `insert-rows [number]` Inserts a row into the sheet at your current row. If the number is provided then inserts that many rows. If omitted then just inserts one. +* `insert-cols [number]` Just line `insert-rows` but for columns. * `rename-sheet [idx] ` rename a sheet. If the idx is provide then renames that sheet. If omitted then it renames the current sheet. * `new-sheet [name]` Creates a new sheet. If the name is provided then uses that. If omitted then uses a default sheet name. * `select-sheet ` Select a sheet by name. -* `edit ` Edit a new spreadsheet at the current path. -* `quit` Quits the application +* `edit ` Edit a new spreadsheet at the current path. `e` is a shorthand alias for this command. +* `quit` Quits the application. `q` is a shorthand alias for this command. - + diff --git a/src/ui/cmd.rs b/src/ui/cmd.rs index f46cef0..f6d7b31 100644 --- a/src/ui/cmd.rs +++ b/src/ui/cmd.rs @@ -108,7 +108,7 @@ fn try_consume_new_sheet<'cmd, 'i: 'cmd>( return Ok(None); } if input.remaining() > 0 && !is_ws(&mut input) { - return Err("Invalid command: Did you mean to type `write `?"); + return Err("Invalid command: Did you mean to type `new-sheet `?"); } let arg = input.span(0..).trim(); return Ok(Some(Cmd::NewSheet(if arg.is_empty() { @@ -129,11 +129,11 @@ fn try_consume_select_sheet<'cmd, 'i: 'cmd>( return Ok(None); } if input.remaining() > 0 && !is_ws(&mut input) { - return Err("Invalid command: Did you mean to type `write `?"); + return Err("Invalid command: Did you mean to type `select-sheet `?"); } let arg = input.span(0..).trim(); if arg.is_empty() { - return Err("Invalid command: Did you forget the sheet name? `write `?"); + return Err("Invalid command: Did you forget the sheet name? `select-sheet `?"); } return Ok(Some(Cmd::SelectSheet(arg))); } @@ -189,7 +189,7 @@ fn try_consume_insert_column<'cmd, 'i: 'cmd>( if let Ok(count) = arg.parse() { count } else { - return Err("You must pass in a non negative number for the row count"); + return Err("You must pass in a non negative number for the column count"); } }))); }