Expand description
§imekit
A cross-platform Rust library for IME (Input Method Engine) integration using native protocols.
This crate provides native protocol implementations for:
- Linux/Wayland:
zwp_input_method_v2andzwp_text_input_v3protocols - Linux/X11: XIM (X Input Method) protocol
- Linux/IBus: IBus D-Bus interface (fallback when Wayland protocol is unavailable)
- Windows: Text Services Framework (TSF)
- macOS: Input Method Kit (IMK)
§Protocol Support
§Linux - Wayland
Uses wayland-protocols-misc for the input-method-unstable-v2 protocol which provides:
- Input method registration and lifecycle
- Text commit and preedit handling
- Surrounding text context
- Popup surface creation for candidate windows
§Linux - X11
Uses XIM (X Input Method) protocol for:
- Full XIM server implementation
- Text commit via XIM protocol or XTest extension
- Preedit handling
§Linux - IBus
Uses IBus D-Bus interface (enabled with ibus feature) as a fallback:
- Works when Wayland input-method protocol is not available
- Provides text commit functionality via IBus
§Windows
Uses the Text Services Framework (TSF) for:
- Input processor registration
- Text composition via SendInput
- Candidate window management
§macOS
Uses the Input Method Kit (IMK) framework for:
- Native NSTextInputClient integration
- Text input handling via CGEvent
§Features
log- Enable logging via thelogcratetracing- Enable logging via thetracingcrateibus- Enable IBus support for Linux (requireszbus)
§Example
use imekit::{InputMethod, InputMethodEvent};
// Create an input method instance
let mut im = InputMethod::new()?;
// Handle events
while let Some(event) = im.next_event() {
match event {
InputMethodEvent::Activate { serial } => {
// IME activated - ready to commit text
im.commit_string("Hello!")?;
im.commit(serial)?;
}
InputMethodEvent::Deactivate => {
// IME deactivated
}
InputMethodEvent::SurroundingText { text, cursor, anchor } => {
// Got surrounding text context
}
_ => {}
}
}Modules§
Structs§
- Content
Hint - Hints about the content type
- Cursor
Rect - Rectangle for cursor/anchor positioning
- Input
Method State - State of the input method (platform-agnostic)
Enums§
- Change
Cause - Cause of a text change
- Content
Purpose - Purpose of the text input
- Display
Server - The display server being used on Linux
- Error
- Errors that can occur during IME operations
- Input
Method - Linux input method that auto-detects display server
- Input
Method Event - Events from the input method system
- Preedit
Style - Preedit style for composing text
Type Aliases§
- Result
- Result type alias for imekit-core operations