#[non_exhaustive]pub struct RunConfig {
pub tick_rate: Duration,
pub mouse: bool,
pub kitty_keyboard: bool,
pub theme: Theme,
pub color_depth: Option<ColorDepth>,
pub max_fps: Option<u32>,
pub scroll_speed: u32,
pub title: Option<String>,
pub widget_theme: WidgetTheme,
pub handle_ctrl_c: bool,
}Expand description
Configuration for a TUI run loop.
Pass to run_with or run_inline_with to customize behavior.
Use Default::default() for sensible defaults (16ms tick / 60fps, no mouse, dark theme).
This type is #[non_exhaustive], so prefer builder methods instead of struct literals.
§Example
use slt::{RunConfig, Theme};
use std::time::Duration;
let config = RunConfig::default()
.tick_rate(Duration::from_millis(50))
.mouse(true)
.theme(Theme::light())
.max_fps(60);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tick_rate: DurationHow long to wait for input before triggering a tick with no events.
Lower values give smoother animations at the cost of more CPU usage. Defaults to 16ms (60fps).
mouse: boolWhether to enable mouse event reporting.
When true, the terminal captures mouse clicks, scrolls, and movement.
Defaults to false.
kitty_keyboard: boolWhether to enable the Kitty keyboard protocol for enhanced input.
When true, enables disambiguated key events, key release events,
and modifier-only key reporting on supporting terminals (kitty, Ghostty, WezTerm).
Terminals that don’t support it silently ignore the request.
Defaults to false.
theme: ThemeThe color theme applied to all widgets automatically.
Defaults to Theme::dark().
color_depth: Option<ColorDepth>Color depth override.
None means auto-detect from $COLORTERM and $TERM environment
variables. Set explicitly to force a specific color depth regardless
of terminal capabilities.
max_fps: Option<u32>Optional maximum frame rate.
None means unlimited frame rate. Some(fps) sleeps at the end of each
loop iteration to target that frame time.
scroll_speed: u32Lines scrolled per mouse scroll event. Defaults to 1.
title: Option<String>Optional terminal window title (set via OSC 2).
widget_theme: WidgetThemeDefault colors applied to all instances of each widget type.
Per-callsite _colored() overrides still take precedence.
Defaults to all-None (use theme colors).
handle_ctrl_c: boolWhether the runtime intercepts Ctrl+C and exits the loop cleanly.
When true (the default), Ctrl+C is treated as a quit signal —
matching the v0.19 behavior. When false, the Ctrl+C key event flows
through to the frame closure as a regular Event::Key, matching
RataTUI’s raw-mode semantics. The user is then responsible for
deciding whether to call Context::quit or treat it as any other
shortcut (e.g. clear input, cancel current operation).
Set this to false when migrating code from RataTUI that already
handles Ctrl+C explicitly, or when implementing a graceful-shutdown
prompt (e.g. “save unsaved changes?”).
§Example
slt::run_with(RunConfig::default().handle_ctrl_c(false), |ui| {
// Ctrl+C now reaches your closure as a normal key event.
if ui.key_mod('c', KeyModifiers::CONTROL) {
// Decide what to do — clear input, prompt to save, quit, etc.
ui.quit();
}
}).unwrap();Implementations§
Source§impl RunConfig
impl RunConfig
Sourcepub fn kitty_keyboard(self, enabled: bool) -> Self
pub fn kitty_keyboard(self, enabled: bool) -> Self
Enable or disable Kitty keyboard protocol.
Sourcepub fn color_depth(self, depth: ColorDepth) -> Self
pub fn color_depth(self, depth: ColorDepth) -> Self
Override the color depth.
Sourcepub fn no_fps_cap(self) -> Self
pub fn no_fps_cap(self) -> Self
Sourcepub fn scroll_speed(self, lines: u32) -> Self
pub fn scroll_speed(self, lines: u32) -> Self
Set the scroll speed (lines per scroll event).
Sourcepub fn widget_theme(self, widget_theme: WidgetTheme) -> Self
pub fn widget_theme(self, widget_theme: WidgetTheme) -> Self
Set default widget colors for all widget types.
Sourcepub fn handle_ctrl_c(self, enabled: bool) -> Self
pub fn handle_ctrl_c(self, enabled: bool) -> Self
Configure whether the runtime auto-exits on Ctrl+C.
Defaults to true (current v0.19 behavior). Set to false to
receive Ctrl+C as a regular Event::Key inside the frame closure
— see RunConfig::handle_ctrl_c for the full migration story.
§Example
use slt::RunConfig;
let cfg = RunConfig::default().handle_ctrl_c(false);
assert!(!cfg.handle_ctrl_c);