Rename Group::Action to Event
This commit is contained in:
parent
15177a529a
commit
6c99f7a53a
3 changed files with 36 additions and 36 deletions
|
|
@ -56,7 +56,7 @@ default_bindings! {
|
||||||
pub fn to_next_unseen_message => ["L", "ctrl+right"];
|
pub fn to_next_unseen_message => ["L", "ctrl+right"];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod tree_op {
|
pub mod tree_action {
|
||||||
pub fn reply => ["r"];
|
pub fn reply => ["r"];
|
||||||
pub fn reply_alternate => ["R"];
|
pub fn reply_alternate => ["R"];
|
||||||
pub fn new_thread => ["t"];
|
pub fn new_thread => ["t"];
|
||||||
|
|
@ -77,7 +77,7 @@ default_bindings! {
|
||||||
pub fn down => [];
|
pub fn down => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod editor_op {
|
pub mod editor_action {
|
||||||
pub fn newline => [];
|
pub fn newline => [];
|
||||||
pub fn backspace => [];
|
pub fn backspace => [];
|
||||||
pub fn delete => [];
|
pub fn delete => [];
|
||||||
|
|
@ -227,28 +227,28 @@ impl Default for EditorCursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Document, Group)]
|
#[derive(Debug, Deserialize, Document, Group)]
|
||||||
pub struct EditorOp {
|
pub struct EditorAction {
|
||||||
/// Insert newline.
|
/// Insert newline.
|
||||||
#[serde(default = "default::editor_op::newline")]
|
#[serde(default = "default::editor_action::newline")]
|
||||||
pub newline: KeyBinding,
|
pub newline: KeyBinding,
|
||||||
/// Delete before cursor.
|
/// Delete before cursor.
|
||||||
#[serde(default = "default::editor_op::backspace")]
|
#[serde(default = "default::editor_action::backspace")]
|
||||||
pub backspace: KeyBinding,
|
pub backspace: KeyBinding,
|
||||||
/// Delete after cursor.
|
/// Delete after cursor.
|
||||||
#[serde(default = "default::editor_op::delete")]
|
#[serde(default = "default::editor_action::delete")]
|
||||||
pub delete: KeyBinding,
|
pub delete: KeyBinding,
|
||||||
/// Clear editor contents.
|
/// Clear editor contents.
|
||||||
#[serde(default = "default::editor_op::clear")]
|
#[serde(default = "default::editor_action::clear")]
|
||||||
pub clear: KeyBinding,
|
pub clear: KeyBinding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for EditorOp {
|
impl Default for EditorAction {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
newline: default::editor_op::newline(),
|
newline: default::editor_action::newline(),
|
||||||
backspace: default::editor_op::backspace(),
|
backspace: default::editor_action::backspace(),
|
||||||
delete: default::editor_op::delete(),
|
delete: default::editor_action::delete(),
|
||||||
clear: default::editor_op::clear(),
|
clear: default::editor_action::clear(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ pub struct Editor {
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[document(no_default)]
|
#[document(no_default)]
|
||||||
pub action: EditorOp,
|
pub action: EditorAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Document, Group)]
|
#[derive(Debug, Deserialize, Document, Group)]
|
||||||
|
|
@ -308,40 +308,40 @@ impl Default for TreeCursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Document, Group)]
|
#[derive(Debug, Deserialize, Document, Group)]
|
||||||
pub struct TreeOp {
|
pub struct TreeAction {
|
||||||
/// Reply to message (inline if possible).
|
/// Reply to message (inline if possible).
|
||||||
#[serde(default = "default::tree_op::reply")]
|
#[serde(default = "default::tree_action::reply")]
|
||||||
pub reply: KeyBinding,
|
pub reply: KeyBinding,
|
||||||
/// Reply to message, opposite of normal reply.
|
/// Reply to message, opposite of normal reply.
|
||||||
#[serde(default = "default::tree_op::reply_alternate")]
|
#[serde(default = "default::tree_action::reply_alternate")]
|
||||||
pub reply_alternate: KeyBinding,
|
pub reply_alternate: KeyBinding,
|
||||||
/// Start a new thread.
|
/// Start a new thread.
|
||||||
#[serde(default = "default::tree_op::new_thread")]
|
#[serde(default = "default::tree_action::new_thread")]
|
||||||
pub new_thread: KeyBinding,
|
pub new_thread: KeyBinding,
|
||||||
/// Fold current message's subtree.
|
/// Fold current message's subtree.
|
||||||
#[serde(default = "default::tree_op::fold_tree")]
|
#[serde(default = "default::tree_action::fold_tree")]
|
||||||
pub fold_tree: KeyBinding,
|
pub fold_tree: KeyBinding,
|
||||||
/// Toggle current message's seen status.
|
/// Toggle current message's seen status.
|
||||||
#[serde(default = "default::tree_op::toggle_seen")]
|
#[serde(default = "default::tree_action::toggle_seen")]
|
||||||
pub toggle_seen: KeyBinding,
|
pub toggle_seen: KeyBinding,
|
||||||
/// Mark all visible messages as seen.
|
/// Mark all visible messages as seen.
|
||||||
#[serde(default = "default::tree_op::mark_visible_seen")]
|
#[serde(default = "default::tree_action::mark_visible_seen")]
|
||||||
pub mark_visible_seen: KeyBinding,
|
pub mark_visible_seen: KeyBinding,
|
||||||
/// Mark all older messages as seen.
|
/// Mark all older messages as seen.
|
||||||
#[serde(default = "default::tree_op::mark_older_seen")]
|
#[serde(default = "default::tree_action::mark_older_seen")]
|
||||||
pub mark_older_seen: KeyBinding,
|
pub mark_older_seen: KeyBinding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TreeOp {
|
impl Default for TreeAction {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
reply: default::tree_op::reply(),
|
reply: default::tree_action::reply(),
|
||||||
reply_alternate: default::tree_op::reply_alternate(),
|
reply_alternate: default::tree_action::reply_alternate(),
|
||||||
new_thread: default::tree_op::new_thread(),
|
new_thread: default::tree_action::new_thread(),
|
||||||
fold_tree: default::tree_op::fold_tree(),
|
fold_tree: default::tree_action::fold_tree(),
|
||||||
toggle_seen: default::tree_op::toggle_seen(),
|
toggle_seen: default::tree_action::toggle_seen(),
|
||||||
mark_visible_seen: default::tree_op::mark_visible_seen(),
|
mark_visible_seen: default::tree_action::mark_visible_seen(),
|
||||||
mark_older_seen: default::tree_op::mark_older_seen(),
|
mark_older_seen: default::tree_action::mark_older_seen(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -354,7 +354,7 @@ pub struct Tree {
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[document(no_default)]
|
#[document(no_default)]
|
||||||
pub action: TreeOp,
|
pub action: TreeAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Document)]
|
#[derive(Debug, Default, Deserialize, Document)]
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub use input::*;
|
||||||
pub use keys::*;
|
pub use keys::*;
|
||||||
|
|
||||||
pub trait Group {
|
pub trait Group {
|
||||||
type Action;
|
type Event;
|
||||||
|
|
||||||
fn action(&self, input: &mut Input) -> Option<Self::Action>;
|
fn event(&self, input: &mut Input) -> Option<Self::Event>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn derive_impl(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let struct_ident = input.ident;
|
let struct_ident = input.ident;
|
||||||
let enum_ident = format_ident!("{}Action", struct_ident);
|
let enum_ident = format_ident!("{}Event", struct_ident);
|
||||||
|
|
||||||
let mut enum_variants = vec![];
|
let mut enum_variants = vec![];
|
||||||
let mut match_cases = vec![];
|
let mut match_cases = vec![];
|
||||||
|
|
@ -38,7 +38,7 @@ pub fn derive_impl(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||||
let description = decapitalize(&docstring);
|
let description = decapitalize(&docstring);
|
||||||
let description = description.strip_suffix('.').unwrap_or(&description);
|
let description = description.strip_suffix('.').unwrap_or(&description);
|
||||||
match_cases.push(quote!{
|
match_cases.push(quote!{
|
||||||
() if input.matches(&self.#field_ident, #description) => Some(Self::Action::#variant_ident),
|
() if input.matches(&self.#field_ident, #description) => Some(Self::Event::#variant_ident),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -50,9 +50,9 @@ pub fn derive_impl(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::cove_input::Group for #struct_ident {
|
impl ::cove_input::Group for #struct_ident {
|
||||||
type Action = #enum_ident;
|
type Event = #enum_ident;
|
||||||
|
|
||||||
fn action(&self, input: &mut ::cove_input::Input) -> Option<Self::Action> {
|
fn event(&self, input: &mut ::cove_input::Input) -> Option<Self::Event> {
|
||||||
match () {
|
match () {
|
||||||
#( #match_cases )*
|
#( #match_cases )*
|
||||||
() => None,
|
() => None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue