fret_runtime/text_interaction_settings.rs
1/// Text interaction settings that affect editor-grade behaviors.
2///
3/// This is intentionally a small, opt-in surface: platform-specific policies (like Linux primary
4/// selection) should be disabled by default so cross-platform apps do not accidentally change UX.
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct TextInteractionSettings {
7 /// When true, selection changes caused by mouse interactions may update the Linux primary
8 /// selection, and middle-click paste will read from primary selection when available.
9 pub linux_primary_selection: bool,
10 /// When true, focused text inputs blink their caret.
11 ///
12 /// This is intentionally opt-in to keep diagnostics and tests deterministic unless the app
13 /// explicitly enables caret blink.
14 pub caret_blink: bool,
15 /// Caret blink toggle interval in milliseconds.
16 ///
17 /// This is a best-effort hint; runners may coalesce timers.
18 pub caret_blink_interval_ms: u16,
19 /// Margin (logical px) used for editor-like horizontal auto-scroll behaviors during pointer
20 /// selection drags, and for keeping the caret comfortably within view while focused.
21 pub horizontal_autoscroll_margin_px: u16,
22 /// Maximum horizontal scroll step (logical px) applied per timer tick while auto-scrolling.
23 pub horizontal_autoscroll_max_step_px: u16,
24}
25
26impl Default for TextInteractionSettings {
27 fn default() -> Self {
28 Self {
29 linux_primary_selection: false,
30 caret_blink: false,
31 caret_blink_interval_ms: 500,
32 horizontal_autoscroll_margin_px: 12,
33 horizontal_autoscroll_max_step_px: 24,
34 }
35 }
36}