keyboard-codes 0.3.0

Cross-platform keyboard key code mapping and conversion
Documentation
//! 高级解析功能示例
//! 运行: cargo run --example advanced_parsing

// use keyboard_codes::*;
use keyboard_codes::{
    parse_shortcut_flexible, parse_shortcut_sequence, CustomKey, CustomKeyMap, Platform,
};

fn main() {
    println!("=== 高级解析功能示例 ===\n");

    // 1. 灵活的分隔符支持
    println!("1. 灵活的分隔符支持:");
    let shortcuts = ["ctrl+c", "ctrl-c", "ctrl c", "ctrl+shift+esc"];
    for shortcut in shortcuts {
        if let Ok(parsed) = parse_shortcut_flexible(shortcut) {
            println!("   '{}' -> {}", shortcut, parsed);
        }
    }

    // 2. 快捷方式序列
    println!("\n2. 快捷方式序列:");
    let sequence = "ctrl+c, ctrl+v, ctrl+z, ctrl+y";
    if let Ok(shortcuts) = parse_shortcut_sequence(sequence) {
        for (i, shortcut) in shortcuts.iter().enumerate() {
            println!("   {}: {}", i + 1, shortcut);
        }
    }

    // 3. 自定义键映射
    println!("\n3. 自定义键映射:");
    let mut custom_map = CustomKeyMap::new();
    let mut custom_key = CustomKey::new("MyCustomKey");
    custom_key
        .add_platform_code(Platform::Windows, 0x100)
        .add_platform_code(Platform::Linux, 500);

    if custom_map.add_key(custom_key).is_ok() {
        println!("   自定义键添加成功");
    }

    println!("\n示例完成!");
}