Crate imekit

Crate imekit 

Source
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_v2 and zwp_text_input_v3 protocols
  • 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 the log crate
  • tracing - Enable logging via the tracing crate
  • ibus - Enable IBus support for Linux (requires zbus)

§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§

wayland_impl
x11_impl

Structs§

ContentHint
Hints about the content type
CursorRect
Rectangle for cursor/anchor positioning
InputMethodState
State of the input method (platform-agnostic)

Enums§

ChangeCause
Cause of a text change
ContentPurpose
Purpose of the text input
DisplayServer
The display server being used on Linux
Error
Errors that can occur during IME operations
InputMethod
Linux input method that auto-detects display server
InputMethodEvent
Events from the input method system
PreeditStyle
Preedit style for composing text

Type Aliases§

Result
Result type alias for imekit-core operations