From 478e3e767cd7a6fe3450e12c3921de76cdc04704 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 26 Apr 2023 15:24:23 +0200 Subject: [PATCH] Add some key binding groups --- Cargo.lock | 1 + cove-input/Cargo.toml | 2 + cove-input/src/groups.rs | 95 ++++++++++++++++++++++++++++++++++++++++ cove-input/src/lib.rs | 2 + 4 files changed, 100 insertions(+) create mode 100644 cove-input/src/groups.rs diff --git a/Cargo.lock b/Cargo.lock index bf3763b..a9e3df1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,6 +290,7 @@ dependencies = [ name = "cove-input" version = "0.6.1" dependencies = [ + "cove-macro", "crossterm", "serde", "serde_either", diff --git a/cove-input/Cargo.toml b/cove-input/Cargo.toml index 2c3c243..61e178f 100644 --- a/cove-input/Cargo.toml +++ b/cove-input/Cargo.toml @@ -4,6 +4,8 @@ version = { workspace = true } edition = { workspace = true } [dependencies] +cove-macro = { path = "../cove-macro" } + crossterm = { workspace = true } serde = { workspace = true } serde_either = { workspace = true } diff --git a/cove-input/src/groups.rs b/cove-input/src/groups.rs new file mode 100644 index 0000000..bf13abe --- /dev/null +++ b/cove-input/src/groups.rs @@ -0,0 +1,95 @@ +use cove_macro::Group; + +use crate::KeyBinding; + +#[derive(Debug, Group)] +pub struct General { + /// Quit cove. + pub exit: KeyBinding, + /// Abort/close. + pub abort: KeyBinding, + /// Confirm. + pub confirm: KeyBinding, + /// Show this help. + pub help: KeyBinding, + /// Show log. + pub log: KeyBinding, +} + +#[derive(Debug, Group)] +pub struct Scroll { + /// Scroll up one line. + pub up_line: KeyBinding, + /// Scroll down one line. + pub down_line: KeyBinding, + /// Scroll up half a screen. + pub up_half: KeyBinding, + /// Scroll down half a screen. + pub down_half: KeyBinding, + /// Scroll up a full screen. + pub up_full: KeyBinding, + /// Scroll down a full screen. + pub down_full: KeyBinding, +} + +#[derive(Debug, Group)] +pub struct Cursor { + /// Move cursor up. + pub up: KeyBinding, + /// Move cursor down. + pub down: KeyBinding, + /// Move cursor to top. + pub to_top: KeyBinding, + /// Move cursor to bottom. + pub to_bottom: KeyBinding, + /// Center cursor. + pub center: KeyBinding, +} + +#[derive(Debug, Group)] +pub struct TreeCursor { + /// Move cursor to above sibling. + pub to_above_sibling: KeyBinding, + /// Move cursor to below sibling. + pub to_below_sibling: KeyBinding, + /// Move cursor to parent. + pub to_parent: KeyBinding, + /// Move cursor to root. + pub to_root: KeyBinding, + /// Move cursor to previous message. + pub to_prev_message: KeyBinding, + /// Move cursor to next message. + pub to_next_message: KeyBinding, +} + +#[derive(Debug, Group)] +pub struct EditorCursor { + /// Move cursor left. + pub left: KeyBinding, + /// Move cursor right. + pub right: KeyBinding, + /// Move cursor left a word. + pub left_word: KeyBinding, + /// Move cursor right a word. + pub right_word: KeyBinding, + /// Move cursor to start of line. + pub start: KeyBinding, + /// Move cursor to end of line. + pub end: KeyBinding, + /// Move cursor up. + pub up: KeyBinding, + /// Move cursor down. + pub down: KeyBinding, +} + +#[derive(Debug, Group)] +pub struct EditorOp { + /// Insert newline. + pub newline: KeyBinding, + /// Delete before cursor. + pub backspace: KeyBinding, + /// Delete after cursor. + pub delete: KeyBinding, + /// Clear editor contents. + pub clear: KeyBinding, +} diff --git a/cove-input/src/lib.rs b/cove-input/src/lib.rs index d3963ee..1ee29d4 100644 --- a/cove-input/src/lib.rs +++ b/cove-input/src/lib.rs @@ -1,6 +1,8 @@ +mod groups; mod input; mod keys; +pub use groups::*; pub use input::*; pub use keys::*;