sui_widgets/
text_command.rs1use sui_runtime::{Command, CommandKey};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum TextCommand {
6 Cut,
7 Copy,
8 Paste,
9 SelectAll,
10}
11
12pub const TEXT_COMMAND: CommandKey<TextCommand> = CommandKey::new("sui.text-command");
14
15impl TextCommand {
16 pub fn from_command(command: &Command<'_>) -> Option<Self> {
17 command.get(TEXT_COMMAND).copied()
18 }
19}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn text_command_key_has_a_stable_diagnostic_name() {
27 assert_eq!(TEXT_COMMAND.name(), "sui.text-command");
28 }
29}