diff --git a/cove-config/src/keys.rs b/cove-config/src/keys.rs index 261c33e..b27a6c8 100644 --- a/cove-config/src/keys.rs +++ b/cove-config/src/keys.rs @@ -1,4 +1,4 @@ -use cove_input::{Group, KeyBinding}; +use cove_input::{KeyBinding, KeyGroup}; use serde::Deserialize; use crate::doc::Document; @@ -86,7 +86,7 @@ default_bindings! { } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct General { /// Quit cove. #[serde(default = "default::general::exit")] @@ -117,7 +117,7 @@ impl Default for General { } } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct Scroll { /// Scroll up one line. #[serde(default = "default::scroll::up_line")] @@ -152,7 +152,7 @@ impl Default for Scroll { } } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct Cursor { /// Move cursor up. #[serde(default = "default::cursor::up")] @@ -183,7 +183,7 @@ impl Default for Cursor { } } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct EditorCursor { /// Move cursor left. #[serde(default = "default::editor_cursor::left")] @@ -226,7 +226,7 @@ impl Default for EditorCursor { } } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct EditorAction { /// Insert newline. #[serde(default = "default::editor_action::newline")] @@ -264,7 +264,7 @@ pub struct Editor { pub action: EditorAction, } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct TreeCursor { /// Move cursor to above sibling. #[serde(default = "default::tree_cursor::to_above_sibling")] @@ -307,7 +307,7 @@ impl Default for TreeCursor { } } -#[derive(Debug, Deserialize, Document, Group)] +#[derive(Debug, Deserialize, Document, KeyGroup)] pub struct TreeAction { /// Reply to message (inline if possible). #[serde(default = "default::tree_action::reply")] diff --git a/cove-input/src/lib.rs b/cove-input/src/lib.rs index 7c0f86d..4129adf 100644 --- a/cove-input/src/lib.rs +++ b/cove-input/src/lib.rs @@ -1,12 +1,13 @@ mod input; mod keys; -pub use cove_macro::Group; +pub use cove_macro::KeyGroup; pub use input::*; pub use keys::*; -pub trait Group { +/// A group of related key bindings. +pub trait KeyGroup { type Event; fn event(&self, input: &mut Input) -> Option; diff --git a/cove-macro/src/group.rs b/cove-macro/src/key_group.rs similarity index 96% rename from cove-macro/src/group.rs rename to cove-macro/src/key_group.rs index 23100d3..83cec49 100644 --- a/cove-macro/src/group.rs +++ b/cove-macro/src/key_group.rs @@ -49,7 +49,7 @@ pub fn derive_impl(input: DeriveInput) -> syn::Result { #( #enum_variants )* } - impl ::cove_input::Group for #struct_ident { + impl ::cove_input::KeyGroup for #struct_ident { type Event = #enum_ident; fn event(&self, input: &mut ::cove_input::Input) -> Option { diff --git a/cove-macro/src/lib.rs b/cove-macro/src/lib.rs index f064a73..82ef61a 100644 --- a/cove-macro/src/lib.rs +++ b/cove-macro/src/lib.rs @@ -12,7 +12,7 @@ use syn::{parse_macro_input, DeriveInput}; mod document; -mod group; +mod key_group; mod util; #[proc_macro_derive(Document, attributes(document))] @@ -24,10 +24,10 @@ pub fn derive_document(input: proc_macro::TokenStream) -> proc_macro::TokenStrea } } -#[proc_macro_derive(Group)] +#[proc_macro_derive(KeyGroup)] pub fn derive_group(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); - match group::derive_impl(input) { + match key_group::derive_impl(input) { Ok(tokens) => tokens.into(), Err(err) => err.into_compile_error().into(), }