### Example of Hangul Layout Addon: TreatJongseongAsChoseongCompose Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Demonstrates the 'TreatJongseongAsChoseongCompose' addon, which composes a previous jongseong with the current choseong, showing an example when 'ComposeChoseongSsang' is active. ```text 읅 + ㄱ = 을ㄲ 앇 + ㅅ = 악ㅆ ``` -------------------------------- ### Example of Hangul Layout Addon: ComposeJungseongSsang Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Demonstrates the 'ComposeJungseongSsang' addon for Hangul, showing the composition of certain vowel combinations. ```text ㅑ + ㅣ = ㅒ ㅕ + ㅣ = ㅖ ``` -------------------------------- ### CMake Project Setup and Options Source: https://github.com/riey/kime/blob/develop/src/CMakeLists.txt Initializes the CMake project, sets the version, and defines boolean options for enabling different frontend immodules (GTK3, GTK4, Qt5, Qt6) and using a system engine. These options control which subdirectories are included in the build. ```cmake cmake_minimum_required(VERSION 3.13.0) project(kime VERSION 2.0.0) option(USE_SYSTEM_ENGINE "Use system engine file" OFF) option(ENABLE_GTK3 "Enable GTK3 immodule" OFF) option(ENABLE_GTK4 "Enable GTK4 immodule" OFF) option(ENABLE_QT5 "Enable Qt5 immodule" OFF) option(ENABLE_QT6 "Enable Qt6 immodule" OFF) ``` -------------------------------- ### Example of Hangul Layout Addon: FlexibleComposeOrder Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Shows the 'FlexibleComposeOrder' addon for Hangul input, allowing for composition of choseong, jungseong, and jongseong even when the order is reversed, aiding in typo correction. ```text ㅏ + ㄱ = 가 ㅚ + ㄱ = 괴 ㅏ + $ㅁ + ㅁ = 맘 ``` -------------------------------- ### Example of Hangul Layout Addon: ComposeJongseongSsang Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Shows the 'ComposeJongseongSsang' addon for Hangul, where pressing the same jongseong twice results in a double jongseong. ```text ㄱ + ㄱ = ㄲ ㅅ + ㅅ = ㅆ ``` -------------------------------- ### Example of Hangul Layout Addon: TreatJongseongAsChoseong Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Illustrates the 'TreatJongseongAsChoseong' addon for Hangul input, showing how a jongseong (final consonant) combined with a vowel is processed as a consonant-vowel pair. ```text 간 + ㅏ = 가나 값 + ㅏ = 갑사 ``` -------------------------------- ### Fedora Installation Command for kime Source: https://github.com/riey/kime/blob/develop/README.md This command enables the kime Copr repository on Fedora and installs the kime package. It also provides an alternative for installing the bleeding-edge version using 'kime-git'. ```sh dnf copr enable toroidalfox/kime dnf install kime # `kime-git` for bleeding edge ``` -------------------------------- ### Example of Hangul Layout Addon: ComposeChoseongSsang Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Illustrates the 'ComposeChoseongSsang' addon for Hangul, where pressing the same choseong twice results in a ssangjaum (double consonant). ```text ㄱ + ㄱ = ㄲ ㅅ + ㅅ = ㅆ ㄷ + ㄷ = ㄸ ㅂ + ㅂ = ㅃ ㅈ + ㅈ = ㅉ ``` -------------------------------- ### YAML Configuration for Kime Layout Addons Source: https://github.com/riey/kime/blob/develop/docs/CONFIGURATION.md Demonstrates the structure for configuring layout addons in kime, specifying addons for all layouts and for the 'dubeolsik' layout. It includes examples of how these addons modify key event processing. ```yaml all: - ComposeChoseongSsang dubeolsik: - TreatJongseongAsChoseong ``` -------------------------------- ### Search and Insert Emoji by Keyword in Rust Source: https://context7.com/riey/kime/llms.txt Shows how to search for and insert emojis using a keyword with the `EmojiMode` struct. The example simulates typing "smile", retrieves emoji suggestions, and commits the first emoji when Enter is pressed. ```rust use kime_engine_backend_emoji::EmojiMode; use kime_engine_backend::{InputEngineBackend, InputEngineMode}; let mut emoji_mode = EmojiMode::new(); let mut commit_buf = String::new(); let latin_config = LatinConfig::default(); // Type search keyword: "smile" for ch in "smile".chars() { let key = Key::new(KeyCode::from_char(ch), ModifierState::empty()); emoji_mode.press_key(&latin_config, key, &mut commit_buf); } // Check preedit for emoji suggestions let mut preedit = String::new(); emoji_mode.preedit_str(&mut preedit); // Shows up to 5 matching emojis: "😀😁😃😄😊" // Press Enter to commit first emoji let enter_key = Key::new(KeyCode::Enter, ModifierState::empty()); match emoji_mode.press_key(&latin_config, enter_key, &mut commit_buf) { InputEngineModeResult::ExitHandled(_) => { println!("Committed: {}", commit_buf); // "😀" } _ => {} } ``` -------------------------------- ### Lookup Hanja, Emoji, and Math Symbols in Rust Source: https://context7.com/riey/kime/llms.txt Illustrates how to use built-in dictionaries to lookup Hanja characters, search for unicode emoji annotations, and lookup math symbols with different styles. This example showcases the dictionary lookup functionality for various character types. ```rust use kime_engine_dict::{lookup, search_unicode_annotations, lookup_math_symbol, Style}; // Hanja dictionary lookup if let Some(entries) = lookup("한국") { for (hanja, description) in entries { println!("{}: {}", hanja, description); } // Output: // 韓國: 나라 이름 // 寒國: 추운 나라 } // Unicode emoji annotation search let results: Vec<_> = search_unicode_annotations("heart") .take(5) .collect(); for annotation in results { println!("{}: {:?}", annotation.emoji, annotation.keywords); } // Output: // ❤: ["heart", "love"] // 💙: ["blue", "heart"] // 💚: ["green", "heart"] // Math symbol lookup with styles let symbols = [ ("alpha", Style::Normal), // α ("alpha", Style::Bold), // 𝛂 ("alpha", Style::Italic), // 𝛼 ("alpha", Style::BoldItalic), // 𝜶 ]; for (name, style) in symbols { if let Some(symbol) = lookup_math_symbol(name, style) { println!("{:?} {}: {}", style, name, symbol); } } ``` -------------------------------- ### GTK Input Method Update Cache Source: https://github.com/riey/kime/blob/develop/README.md These commands update the input method cache for GTK3 and GTK4. This step is typically necessary when installing kime from source or if the system's input method modules are not automatically updated, ensuring GTK applications recognize kime. ```sh # for gtk3 sudo gtk-query-immodules-3.0 --update-cache # for gtk4 sudo gio-querymodules /usr/lib/gtk-4.0/4.0.0/immodules ``` -------------------------------- ### Initialize XIM Server in Rust Source: https://context7.com/riey/kime/llms.txt Sets up and runs the XIM server for X11 window systems. It connects to X11, loads configuration, creates an input handler, and enters an event loop to process X11 events and forward them to the XIM server. ```rust use kime_xim::{KimeHandler, KimeData}; use xim::{XimServer, XimServerHandler}; use x11rb::connection::Connection; // Initialize X11 connection let (conn, screen) = x11rb::connect(None).unwrap(); let screen = conn.setup().roots[screen].clone(); // Load configuration let config = Config::load().unwrap_or_default(); let font = load_font(&config.xim_preedit_font); // Create XIM handler let handler = KimeHandler::new(screen, font, config); // Create XIM server let mut xim_server = XimServer::new( Box::new(conn.clone()), "kime", "KIME", handler, ); // Event loop loop { // Process X11 events let event = conn.wait_for_event().unwrap(); // Forward to XIM server xim_server.handle_event(&event); // XIM server callbacks will: // 1. Receive key events from client // 2. Process through InputEngine // 3. Update preedit windows // 4. Send commit strings to client } ``` -------------------------------- ### Docker Build and Run for kime Source: https://github.com/riey/kime/blob/develop/README.md This set of commands demonstrates how to build and run kime using Docker. It clones the repository, builds a Docker image, runs a container to perform the build, and then copies the output artifacts (like a tar.zst archive or a deb package) from the container. ```sh git clone https://github.com/riey/kime cd kime docker build --file build-docker//Dockerfile --tag kime-build:git . docker run --name kime kime-build:git docker cp kime:/opt/kime-out/kime.tar.zst . # if you want to build deb package try this command instead # docker cp kime:/opt/kime-out/kime_amd64.deb . ``` -------------------------------- ### Load and Configure Kime Settings in Rust Source: https://context7.com/riey/kime/llms.txt Demonstrates how to load Kime's configuration from a file or create a default configuration programmatically in Rust. It shows how to access and modify settings like the default input category and global category state, and specifically access Hangul input settings. ```rust use kime_engine_core::{Config, InputCategory, InputMode}; // Load configuration from file let config = Config::load_from_config_dir().unwrap_or_default(); // Or create programmatically let mut config = Config::default(); config.default_category = InputCategory::Hangul; config.global_category_state = true; // Access hangul settings let layout_name = &config.hangul.layout; let word_commit = config.hangul.word_commit; println!("Using layout: {}, word_commit: {}", layout_name, word_commit); ``` -------------------------------- ### C FFI API: Integrate KIME Engine with Applications Source: https://context7.com/riey/kime/llms.txt Shows how to use the C Foreign Function Interface (FFI) for KIME, including checking API version, loading configuration, creating an engine instance, setting input category, processing key presses via hardware codes, and retrieving pre-edit and commit strings. Proper cleanup is also demonstrated. ```c #include #include int main() { // Check API version compatibility size_t version = kime_api_version(); printf("KIME API version: %zu\n", version); // Load configuration from system/user config file Config* config = kime_config_load(); if (!config) { config = kime_config_default(); } // Create new engine instance InputEngine* engine = kime_engine_new(config); // Set initial input category to Hangul kime_engine_set_input_category(engine, InputCategory_Hangul); // Process hardware keycode with modifiers // hardware_code=19 is 'r' key, maps to 'ㄱ' in Korean layout uint16_t hardware_code = 19; bool numlock = false; ModifierState state = ModifierState_empty(); InputResult result = kime_engine_press_key( engine, config, hardware_code, numlock, state ); // Check result flags if (result & InputResult_CONSUMED) { printf("Key consumed by engine\n"); } if (result & InputResult_HAS_PREEDIT) { RustStr preedit = kime_engine_preedit_str(engine); printf("Preedit: %.*s\n", (int)preedit.len, preedit.ptr); } if (result & InputResult_HAS_COMMIT) { RustStr commit = kime_engine_commit_str(engine); printf("Commit: %.*s\n", (int)commit.len, commit.ptr); kime_engine_clear_commit(engine); } // Clean up kime_engine_delete(engine); kime_config_delete(config); return 0; } ``` -------------------------------- ### Rust Core Engine API: Process Keyboard Input Source: https://context7.com/riey/kime/llms.txt Demonstrates initializing the KIME engine, setting input categories, processing key presses, and handling pre-edit and commit strings using the Rust API. It also shows how to toggle between Hangul and Latin input modes and reset the engine. ```rust use kime_engine_core::{InputEngine, Config, InputResult, InputCategory, Key, KeyCode, ModifierState}; // Initialize engine with default configuration let config = Config::default(); let mut engine = InputEngine::new(&config); // Set input category to Korean engine.set_input_category(InputCategory::Hangul); // Process key press (example: pressing 'ㄱ' key on Korean keyboard) let key = Key::new(KeyCode::R, ModifierState::empty()); let result = engine.press_key(key, &config); if result.contains(InputResult::CONSUMED) { println!("Key was handled by engine"); } if result.contains(InputResult::HAS_PREEDIT) { // Get uncommitted text being composed let preedit = engine.preedit_str(); println!("Composing: {}", preedit); } if result.contains(InputResult::HAS_COMMIT) { // Get completed text ready to commit let commit = engine.commit_str(); println!("Commit: {}", commit); engine.clear_commit(); } // Toggle between Hangul and Latin input let current = engine.category(); let new_category = match current { InputCategory::Hangul => InputCategory::Latin, InputCategory::Latin => InputCategory::Hangul, }; engine.set_input_category(new_category); if result.contains(InputResult::LANGUAGE_CHANGED) { println!("Input language changed"); } // Reset engine state engine.reset(); ``` -------------------------------- ### CMake Configure kime-qt6 Library Directories and Libraries Source: https://github.com/riey/kime/blob/develop/src/frontends/qt6/CMakeLists.txt Configures the include and link directories, and links the necessary libraries for the kime-qt6 target. It includes Qt6 and Qt5 private include directories, KIME include directories, KIME library directories, and links against the KIME engine and Qt6::Gui. ```cmake target_include_directories(kime-qt6 PRIVATE ${Qt6Gui_PRIVATE_INCLUDE_DIRS} ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${KIME_INCLUDE}) target_link_directories(kime-qt6 PRIVATE ${KIME_LIB_DIRS}) target_link_libraries(kime-qt6 PRIVATE ${KIME_ENGINE} Qt6::Gui) ``` -------------------------------- ### KIME Daemon and System Integration in Rust and Shell Source: https://context7.com/riey/kime/llms.txt Manages the main KIME daemon process and integrates with the system environment. It spawns enabled modules (XIM, Wayland, Indicator) as child processes and includes logic for monitoring and respawning them if they crash. Shell commands are provided for setting up environment variables. ```rust use kime_tools_kime::{DaemonConfig, DaemonModule}; use std::process::{Command, Child}; // Load daemon configuration let config = DaemonConfig::load().unwrap_or_default(); let mut processes: Vec = Vec::new(); // Spawn enabled modules if config.modules.contains(DaemonModule::Xim) { let child = Command::new("kime-xim") .spawn() .expect("Failed to start XIM"); processes.push(child); } if config.modules.contains(DaemonModule::Wayland) { let child = Command::new("kime-wayland") .spawn() .expect("Failed to start Wayland"); processes.push(child); } if config.modules.contains(DaemonModule::Indicator) { let child = Command::new("kime-indicator") .spawn() .expect("Failed to start Indicator"); processes.push(child); } // Monitor processes and respawn if crashed loop { for (i, child) in processes.iter_mut().enumerate() { if let Ok(Some(status)) = child.try_wait() { eprintln!("Process {} exited with status: {}", i, status); // Respawn logic here } } std::thread::sleep(std::time::Duration::from_secs(1)); } ``` ```shell # System environment setup for XIM/Wayland # Add to ~/.xprofile or shell rc file export GTK_IM_MODULE=kime export QT_IM_MODULE=kime export XMODIFIERS=@im=kime # Start KIME daemon (usually auto-started via XDG autostart) kime & ``` -------------------------------- ### Weston Configuration for kime Input Method Source: https://github.com/riey/kime/blob/develop/README.md This configuration block specifies the path to the kime input method binary within the Weston compositor's configuration file. It ensures that Weston can locate and launch the kime daemon for input method services. ```ini [input-method] path=/usr/bin/kime ``` -------------------------------- ### Core Engine API - Rust Source: https://context7.com/riey/kime/llms.txt Demonstrates the usage of the `InputEngine` in Rust for processing keyboard input, managing input states, and handling different input categories like Hangul and Latin. ```APIDOC ## Rust Core Engine API ### Description This section details the core Rust API for the KIME engine, showing how to initialize, process input, and manage states. ### Method Rust API (In-memory calls) ### Endpoint N/A ### Parameters N/A ### Request Example ```rust use kime_engine_core::{InputEngine, Config, InputResult, InputCategory, Key, KeyCode, ModifierState}; // Initialize engine with default configuration let config = Config::default(); let mut engine = InputEngine::new(&config); // Set input category to Korean engine.set_input_category(InputCategory::Hangul); // Process key press (example: pressing 'ㄱ' key on Korean keyboard) let key = Key::new(KeyCode::R, ModifierState::empty()); let result = engine.press_key(key, &config); if result.contains(InputResult::CONSUMED) { println!("Key was handled by engine"); } if result.contains(InputResult::HAS_PREEDIT) { // Get uncommitted text being composed let preedit = engine.preedit_str(); println!("Composing: {}", preedit); } if result.contains(InputResult::HAS_COMMIT) { // Get completed text ready to commit let commit = engine.commit_str(); println!("Commit: {}", commit); engine.clear_commit(); } // Toggle between Hangul and Latin input let current = engine.category(); let new_category = match current { InputCategory::Hangul => InputCategory::Latin, InputCategory::Latin => InputCategory::Hangul, }; engine.set_input_category(new_category); if result.contains(InputResult::LANGUAGE_CHANGED) { println!("Input language changed"); } // Reset engine state engine.reset(); ``` ### Response N/A (In-memory operations) ### Response Example N/A ``` -------------------------------- ### Initialize Wayland Input Method in Rust Source: https://context7.com/riey/kime/llms.txt Implements input method functionality for Wayland compositors. It connects to the Wayland compositor, initializes the input method protocol (v2 or v1), and sets up an event loop to handle compositor events and manage input. ```rust use wayland_client::{Connection, Dispatch}; use kime_wayland::{WaylandHandler, InputEngine}; // Connect to Wayland compositor let conn = Connection::connect_to_env().unwrap(); let mut event_queue = conn.new_event_queue(); let qh = event_queue.handle(); // Get compositor globals let display = conn.display(); let globals = display.get_registry(&qh, ()); // Initialize input method v2 or v1 let input_method = if let Some(v2) = globals.bind::() { InputMethodVersion::V2(v2) } else { InputMethodVersion::V1(globals.bind::().unwrap()) }; // Create engine and handler let config = Config::load().unwrap_or_default(); let engine = InputEngine::new(&config); let mut handler = WaylandHandler::new(engine, input_method); // Event loop loop { event_queue.blocking_dispatch(&mut handler).unwrap(); // Handler processes: // - Key events from compositor // - Sends preedit updates // - Commits text to focused application } ``` -------------------------------- ### C Foreign Function Interface (FFI) API Source: https://context7.com/riey/kime/llms.txt Details the C API for integrating the KIME engine with applications, providing functions for initialization, input processing, and state management compatible with GTK and Qt. ```APIDOC ## C Foreign Function Interface (FFI) API ### Description This section describes the C Foreign Function Interface (FFI) for KIME, enabling integration with C-based applications and frameworks like GTK and Qt. ### Method C API (Library calls) ### Endpoint N/A ### Parameters N/A ### Request Example ```c #include #include int main() { // Check API version compatibility size_t version = kime_api_version(); printf("KIME API version: %zu\n", version); // Load configuration from system/user config file Config* config = kime_config_load(); if (!config) { config = kime_config_default(); } // Create new engine instance InputEngine* engine = kime_engine_new(config); // Set initial input category to Hangul kime_engine_set_input_category(engine, InputCategory_Hangul); // Process hardware keycode with modifiers // hardware_code=19 is 'r' key, maps to 'ㄱ' in Korean layout uint16_t hardware_code = 19; bool numlock = false; ModifierState state = ModifierState_empty(); InputResult result = kime_engine_press_key( engine, config, hardware_code, numlock, state ); // Check result flags if (result & InputResult_CONSUMED) { printf("Key consumed by engine\n"); } if (result & InputResult_HAS_PREEDIT) { RustStr preedit = kime_engine_preedit_str(engine); printf("Preedit: %.*s\n", (int)preedit.len, preedit.ptr); } if (result & InputResult_HAS_COMMIT) { RustStr commit = kime_engine_commit_str(engine); printf("Commit: %.*s\n", (int)commit.len, commit.ptr); kime_engine_clear_commit(engine); } // Clean up kime_engine_delete(engine); kime_config_delete(config); return 0; } ``` ### Response N/A (C library calls) ### Response Example N/A ``` -------------------------------- ### Manual Build Script for kime Source: https://github.com/riey/kime/blob/develop/README.md This command executes the `build.sh` script for a manual build of kime. The `-ar` flags typically indicate build for all architectures and release mode. The script compiles the project, and the output files are placed in the `build/out` directory. ```sh git clone https://github.com/riey/kime cd kime scripts/build.sh -ar ``` -------------------------------- ### CMake Frontend Integration and Library Paths Source: https://github.com/riey/kime/blob/develop/src/CMakeLists.txt Sets up include directories for the kime engine and determines library search paths based on the USE_SYSTEM_ENGINE option. It conditionally includes subdirectories for different frontends (GTK3, GTK4, Qt5, Qt6) if their respective options are enabled. ```cmake set(KIME_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/engine/capi) if(${USE_SYSTEM_ENGINE}) set(KIME_LIB_DIRS "") else() set(KIME_LIB_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../target/debug ${CMAKE_CURRENT_SOURCE_DIR}/../target/release) endif() set(KIME_ENGINE kime_engine) set(OpenGL_GL_PREFERENCE GLVND) include(GNUInstallDirs) if(${ENABLE_GTK3}) add_subdirectory(frontends/gtk3) endif() if(${ENABLE_GTK4}) add_subdirectory(frontends/gtk4) endif() if(${ENABLE_QT5}) add_subdirectory(frontends/qt5) endif() if(${ENABLE_QT6}) add_subdirectory(frontends/qt6) endif() ``` -------------------------------- ### Hangul Engine: Korean Character Composition in Rust Source: https://context7.com/riey/kime/llms.txt Illustrates the usage of the `kime_engine_backend_hangul` in Rust for composing Korean characters. It covers initialization, character composition step-by-step using specific keys and addons, displaying pre-edit text, committing characters, and handling backspace operations. ```rust use kime_engine_backend_hangul::{HangulEngine, PreeditJohabLevel, Addon}; use kime_engine_backend::{InputEngineBackend, Key, KeyCode, ModifierState}; use enumset::EnumSet; // Create hangul engine with word commit mode enabled let mut engine = HangulEngine::new(true, PreeditJohabLevel::Disable); let mut commit_buf = String::new(); // Configure addons for flexible composition let mut addons = EnumSet::new(); addons.insert(Addon::FlexibleComposeOrder); addons.insert(Addon::TreatJongseongAsChoseong); // Compose "한" character step by step // ㅎ (choseong/initial consonant) let key_h = Key::new(KeyCode::G, ModifierState::empty()); engine.key(KeyValue::from('ㅎ'), addons, &mut commit_buf); let mut preedit = String::new(); engine.preedit_str(&mut preedit); assert_eq!(preedit, "ㅎ"); // ㅏ (jungseong/vowel) engine.key(KeyValue::from('ㅏ'), addons, &mut commit_buf); preedit.clear(); engine.preedit_str(&mut preedit); assert_eq!(preedit, "하"); // ㄴ (jongseong/final consonant) engine.key(KeyValue::from('ㄴ'), addons, &mut commit_buf); preedit.clear(); engine.preedit_str(&mut preedit); assert_eq!(preedit, "한"); // Clear preedit commits the character preedit.clear(); commit_buf.clear(); engine.clear_preedit(&mut commit_buf); assert_eq!(commit_buf, "한"); // Backspace support engine.key(KeyValue::from('ㅎ'), addons, &mut commit_buf); engine.key(KeyValue::from('ㅏ'), addons, &mut commit_buf); engine.backspace(addons, &mut commit_buf); // Back to "ㅎ" preedit.clear(); engine.preedit_str(&mut preedit); assert_eq!(preedit, "ㅎ"); ``` -------------------------------- ### Input Mathematical Symbols and Greek Letters with Style Variants in Rust Source: https://context7.com/riey/kime/llms.txt Demonstrates how to input mathematical symbols and Greek letters with different styles using the `MathMode` struct. It shows how to input "\alpha" and "\bitalpha" to produce normal and bold italic alpha symbols, respectively. Also shows direct symbol lookup from dictionary. ```rust use kime_engine_backend_math::{MathMode, Style}; use kime_engine_backend::{InputEngineBackend, Key, KeyCode}; let mut math_mode = MathMode::new(); let mut commit_buf = String::new(); let latin_config = LatinConfig::default(); // Type "\alpha" for Greek letter alpha for ch in "\\alpha".chars() { let key = Key::new(KeyCode::from_char(ch), ModifierState::empty()); math_mode.press_key(&latin_config, key, &mut commit_buf); } let mut preedit = String::new(); math_mode.preedit_str(&mut preedit); assert_eq!(preedit, "α"); // Clear and try bold italic alpha: "\bitalpha" math_mode.reset(); commit_buf.clear(); for ch in "\\bitalpha".chars() { let key = Key::new(KeyCode::from_char(ch), ModifierState::empty()); math_mode.press_key(&latin_config, key, &mut commit_buf); } preedit.clear(); math_mode.preedit_str(&mut preedit); assert_eq!(preedit, "𝜶"); // Bold italic alpha // Direct symbol lookup use kime_engine_dict::lookup_math_symbol; let symbol = lookup_math_symbol("alpha", Style::Normal); assert_eq!(symbol, Some("α")); let bold_alpha = lookup_math_symbol("alpha", Style::Bold); assert_eq!(bold_alpha, Some("𝛂")); ``` -------------------------------- ### CMake C++ Standard and Qt Auto Build Configuration Source: https://github.com/riey/kime/blob/develop/src/frontends/qt6/CMakeLists.txt Sets the C++ standard to C++20 and enables Qt's automatic moc, rcc, and uic build steps. These are essential for projects using Qt's meta-object system and resource files. ```cmake set(CMAKE_CXX_STANDARD 20) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) ``` -------------------------------- ### CMake Compiler Flags and Output Directories Source: https://github.com/riey/kime/blob/develop/src/CMakeLists.txt Configures C and C++ compiler flags, setting them to include verbose warnings and hidden visibility. It also specifies the output directories for libraries and runtime executables, placing them in 'lib' and 'bin' subdirectories within the binary directory, respectively. Debug builds include the '-DDEBUG' preprocessor definition. ```cmake set(CMAKE_SKIP_RPATH TRUE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) ``` -------------------------------- ### CMake Find Qt6 and Qt5 Packages Source: https://github.com/riey/kime/blob/develop/src/frontends/qt6/CMakeLists.txt Attempts to find Qt6 and Qt5 packages, specifically requiring the Gui component. The `QUIET` flag prevents excessive output if packages are not found. The build proceeds only if Qt6 is found. ```cmake find_package(Qt6 6.0.0 QUIET COMPONENTS Gui QUIET) find_package(Qt5 5.1.0 QUIET COMPONENTS Gui QUIET) if(NOT Qt6_FOUND) return() endif() ``` -------------------------------- ### Generate C/C++ Intellisense for VS Code Source: https://github.com/riey/kime/blob/develop/README.md This command generates necessary files for C/C++ intellisense within Visual Studio Code. It relies on the `generate_properties.sh` script provided in the kime project, which likely creates configuration files like `compile_commands.json` or similar. ```sh Run ./scripts/generate_properties.sh for using intellisense C/C++ in vscode ``` -------------------------------- ### CMake Add kime-qt6 Shared Library Source: https://github.com/riey/kime/blob/develop/src/frontends/qt6/CMakeLists.txt Adds a shared library target named 'kime-qt6' using the specified C++ source files. This library will be dynamically linked at runtime. ```cmake add_library(kime-qt6 SHARED ../qt5/src/plugin.cc ../qt5/src/input_context.cc) ``` -------------------------------- ### Define Custom Korean Keyboard Layouts in YAML Source: https://context7.com/riey/kime/llms.txt Specifies how to define custom Korean keyboard layouts using YAML format. This includes mapping physical keys to characters (with shift states) and defining rules for character composition, such as combining consonants and vowels. ```yaml # ~/.config/kime/layouts/my_custom_layout.yaml name: my_custom_layout # Map keys to Korean characters keymap: # Key: [normal, shift] q: [ㅂ, ㅃ] w: [ㅈ, ㅉ] e: [ㄷ, ㄸ] r: [ㄱ, ㄲ] t: [ㅅ, ㅆ] y: [ㅛ, null] u: [ㅕ, null] i: [ㅑ, null] o: [ㅐ, ㅒ] p: [ㅔ, ㅖ] a: [ㅁ, null] s: [ㄴ, null] d: [ㅇ, null] f: [ㄹ, null] g: [ㅎ, null] h: [ㅗ, null] j: [ㅓ, null] k: [ㅏ, null] l: [ㅣ, null] z: [ㅋ, null] x: [ㅌ, null] c: [ㅊ, null] v: [ㅍ, null] b: [ㅠ, null] n: [ㅜ, null] m: [ㅡ, null] # Character composition rules compose: # Combine consonants ㄱ + ㄱ: ㄲ ㄷ + ㄷ: ㄸ ㅂ + ㅂ: ㅃ ㅅ + ㅅ: ㅆ ㅈ + ㅈ: ㅉ # Combine vowels ㅗ + ㅏ: ㅘ ㅗ + ㅐ: ㅙ ㅗ + ㅣ: ㅚ ㅜ + ㅓ: ㅝ ㅜ + ㅔ: ㅞ ㅜ + ㅣ: ㅟ ㅡ + ㅣ: ㅢ # Final consonant combinations ㄱ + ㅅ: ㄳ ㄴ + ㅈ: ㄵ ㄴ + ㅎ: ㄶ ㄹ + ㄱ: ㄺ ㄹ + ㅁ: ㄻ ㄹ + ㅂ: ㄼ ㄹ + ㅅ: ㄽ ㄹ + ㅌ: ㄾ ㄹ + ㅍ: ㄿ ㄹ + ㅎ: ㅀ ㅂ + ㅅ: ㅄ ``` ```yaml # Reference custom layout in config.yaml engine: hangul: layout: my_custom_layout addons: my_custom_layout: - FlexibleComposeOrder ``` -------------------------------- ### Environment Variables for Input Method Modules Source: https://github.com/riey/kime/blob/develop/README.md This snippet shows how to set environment variables to configure graphical applications to use kime as their input method module. These variables (GTK_IM_MODULE, QT_IM_MODULE, XMODIFIERS) are commonly used across different desktop environments and toolkits. ```sh export GTK_IM_MODULE=kime export QT_IM_MODULE=kime export XMODIFIERS=@im=kime if you use X, append above lines to file `~/.xprofile` ``` -------------------------------- ### Enter Hanja Mode with Korean Text in Rust Source: https://context7.com/riey/kime/llms.txt Demonstrates how to enter Hanja mode, set a Korean key, and retrieve the selected Hanja character. This snippet shows how to use the `HanjaMode` struct to allow users to select Chinese characters from Korean input. ```rust use kime_engine_backend_hanja::HanjaMode; use kime_engine_candidate::Client; // Enter hanja mode with Korean text let mut hanja_mode = HanjaMode::new(); // Search for hanja matching "한국" (Korea) let success = hanja_mode.set_key("한국"); assert!(success); // This spawns a candidate window process // User sees: 1.韓國 2.寒國 3.汗國 ... // User presses '1' to select // Check if user has made selection if hanja_mode.check_ready() { let mut commit_buf = String::new(); // Get selected hanja match hanja_mode.end_ready(&mut commit_buf) { InputEngineModeResult::ExitHandled(_) => { println!("Selected: {}", commit_buf); // "韓國" } _ => { println!("Selection cancelled"); } } } ``` -------------------------------- ### NixOS Configuration for kime Source: https://github.com/riey/kime/blob/develop/README.md This snippet configures kime as the input method on NixOS. It sets the default locale and enables the input method, specifying 'kime' as the type and allowing customization of the indicator icon color. ```nix i18n = { defaultLocale = "en_US.UTF-8"; inputMethod = { enable = true; type = "kime"; kime.config = { indicator.icon_color = "White"; }; }; }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.