floem/views/editor/
command.rs

1use floem_editor_core::command::{
2    EditCommand, MotionModeCommand, MoveCommand, MultiSelectionCommand, ScrollCommand,
3};
4use strum::EnumMessage;
5
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub enum Command {
8    Edit(EditCommand),
9    Move(MoveCommand),
10    Scroll(ScrollCommand),
11    MotionMode(MotionModeCommand),
12    MultiSelection(MultiSelectionCommand),
13}
14
15impl Command {
16    pub fn desc(&self) -> Option<&'static str> {
17        match &self {
18            Command::Edit(cmd) => cmd.get_message(),
19            Command::Move(cmd) => cmd.get_message(),
20            Command::Scroll(cmd) => cmd.get_message(),
21            Command::MotionMode(cmd) => cmd.get_message(),
22            Command::MultiSelection(cmd) => cmd.get_message(),
23        }
24    }
25
26    pub fn str(&self) -> &'static str {
27        match &self {
28            Command::Edit(cmd) => cmd.into(),
29            Command::Move(cmd) => cmd.into(),
30            Command::Scroll(cmd) => cmd.into(),
31            Command::MotionMode(cmd) => cmd.into(),
32            Command::MultiSelection(cmd) => cmd.into(),
33        }
34    }
35}
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub enum CommandExecuted {
39    Yes,
40    No,
41}