mod error;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
mod unsupported;
pub use error::ImSwitchError;
#[cfg(target_os = "linux")]
use linux as platform;
#[cfg(target_os = "windows")]
use windows as platform;
#[cfg(target_os = "macos")]
use macos as platform;
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
use unsupported as platform;
pub fn get_input_method() -> Result<String, ImSwitchError> {
platform::get_input_method()
}
pub fn set_input_method(im: &str) -> Result<(), ImSwitchError> {
platform::set_input_method(im)
}
pub fn list_input_methods() -> Result<Vec<String>, ImSwitchError> {
platform::list_input_methods()
}
#[cfg(target_os = "windows")]
pub fn get_ime_state() -> Result<bool, ImSwitchError> {
platform::get_ime_state()
}
#[cfg(target_os = "windows")]
pub fn set_ime_state(enabled: bool) -> Result<(), ImSwitchError> {
platform::set_ime_state(enabled)
}
#[cfg(target_os = "windows")]
pub fn toggle_ime_state() -> Result<bool, ImSwitchError> {
let current = get_ime_state()?;
let new_state = !current;
set_ime_state(new_state)?;
Ok(new_state)
}