pub struct CustomKey { /* private fields */ }Expand description
Custom key definition
Implementations§
Source§impl CustomKey
impl CustomKey
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Create a new custom key with the given name
Examples found in repository?
examples/advanced_parsing.rs (line 33)
9fn main() {
10 println!("=== 高级解析功能示例 ===\n");
11
12 // 1. 灵活的分隔符支持
13 println!("1. 灵活的分隔符支持:");
14 let shortcuts = ["ctrl+c", "ctrl-c", "ctrl c", "ctrl+shift+esc"];
15 for shortcut in shortcuts {
16 if let Ok(parsed) = parse_shortcut_flexible(shortcut) {
17 println!(" '{}' -> {}", shortcut, parsed);
18 }
19 }
20
21 // 2. 快捷方式序列
22 println!("\n2. 快捷方式序列:");
23 let sequence = "ctrl+c, ctrl+v, ctrl+z, ctrl+y";
24 if let Ok(shortcuts) = parse_shortcut_sequence(sequence) {
25 for (i, shortcut) in shortcuts.iter().enumerate() {
26 println!(" {}: {}", i + 1, shortcut);
27 }
28 }
29
30 // 3. 自定义键映射
31 println!("\n3. 自定义键映射:");
32 let mut custom_map = CustomKeyMap::new();
33 let mut custom_key = CustomKey::new("MyCustomKey");
34 custom_key
35 .add_platform_code(Platform::Windows, 0x100)
36 .add_platform_code(Platform::Linux, 500);
37
38 if custom_map.add_key(custom_key).is_ok() {
39 println!(" 自定义键添加成功");
40 }
41
42 println!("\n示例完成!");
43}Sourcepub fn add_platform_code(
&mut self,
platform: Platform,
code: usize,
) -> &mut Self
pub fn add_platform_code( &mut self, platform: Platform, code: usize, ) -> &mut Self
Add a platform-specific code mapping for this key
Examples found in repository?
examples/advanced_parsing.rs (line 35)
9fn main() {
10 println!("=== 高级解析功能示例 ===\n");
11
12 // 1. 灵活的分隔符支持
13 println!("1. 灵活的分隔符支持:");
14 let shortcuts = ["ctrl+c", "ctrl-c", "ctrl c", "ctrl+shift+esc"];
15 for shortcut in shortcuts {
16 if let Ok(parsed) = parse_shortcut_flexible(shortcut) {
17 println!(" '{}' -> {}", shortcut, parsed);
18 }
19 }
20
21 // 2. 快捷方式序列
22 println!("\n2. 快捷方式序列:");
23 let sequence = "ctrl+c, ctrl+v, ctrl+z, ctrl+y";
24 if let Ok(shortcuts) = parse_shortcut_sequence(sequence) {
25 for (i, shortcut) in shortcuts.iter().enumerate() {
26 println!(" {}: {}", i + 1, shortcut);
27 }
28 }
29
30 // 3. 自定义键映射
31 println!("\n3. 自定义键映射:");
32 let mut custom_map = CustomKeyMap::new();
33 let mut custom_key = CustomKey::new("MyCustomKey");
34 custom_key
35 .add_platform_code(Platform::Windows, 0x100)
36 .add_platform_code(Platform::Linux, 500);
37
38 if custom_map.add_key(custom_key).is_ok() {
39 println!(" 自定义键添加成功");
40 }
41
42 println!("\n示例完成!");
43}Trait Implementations§
impl Eq for CustomKey
impl StructuralPartialEq for CustomKey
Auto Trait Implementations§
impl Freeze for CustomKey
impl RefUnwindSafe for CustomKey
impl Send for CustomKey
impl Sync for CustomKey
impl Unpin for CustomKey
impl UnwindSafe for CustomKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more