mod error;
use crate::shutdown_handler::ShutdownManager;
use anyhow::Result;
pub use error::Error;
pub trait CursorPositionProvider {
fn get_cursor_position(&self) -> Result<(i32, i32)>;
fn get_active_window(&self) -> Result<WindowInfo>;
}
#[derive(Debug, Clone, Default)]
pub struct InsertOptions {
pub auto_capitalize: bool,
pub auto_punctuate: bool,
pub insertion_delay: Option<std::time::Duration>,
}
pub trait TextInserter {
fn insert_text(&self, text: &str) -> Result<()>;
fn insert_text_with_options(&self, text: &str, options: InsertOptions) -> Result<()>;
}
pub trait PlatformHandler: CursorPositionProvider + TextInserter {
fn is_supported() -> bool where Self: Sized;
fn register_shutdown(&self, manager: &ShutdownManager) -> Result<()>;
}
#[derive(Debug, Clone)]
pub struct WindowInfo {
pub id: u64,
pub title: String,
pub app_name: String,
}
#[derive(Debug, Default, Clone)]
pub enum TextFormat {
#[default]
Plain,
RichText(Vec<TextStyle>),
}
#[derive(Debug, Clone)]
pub enum TextStyle {
Bold,
Italic,
Underline,
FontSize(u8),
}