Skip to main content

RunConfig

Struct RunConfig 

Source
#[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>, }
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).

§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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§tick_rate: Duration

How 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: bool

Whether to enable mouse event reporting.

When true, the terminal captures mouse clicks, scrolls, and movement. Defaults to false.

§kitty_keyboard: bool

Whether 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: Theme

The 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: u32

Lines scrolled per mouse scroll event. Defaults to 1.

§title: Option<String>

Optional terminal window title (set via OSC 2).

Implementations§

Source§

impl RunConfig

Source

pub fn tick_rate(self, rate: Duration) -> Self

Set the tick rate (input polling interval).

Source

pub fn mouse(self, enabled: bool) -> Self

Enable or disable mouse event reporting.

Source

pub fn kitty_keyboard(self, enabled: bool) -> Self

Enable or disable Kitty keyboard protocol.

Source

pub fn theme(self, theme: Theme) -> Self

Set the color theme.

Source

pub fn color_depth(self, depth: ColorDepth) -> Self

Override the color depth.

Source

pub fn max_fps(self, fps: u32) -> Self

Set the maximum frame rate.

Source

pub fn scroll_speed(self, lines: u32) -> Self

Set the scroll speed (lines per scroll event).

Source

pub fn title(self, title: impl Into<String>) -> Self

Set the terminal window title.

Trait Implementations§

Source§

impl Default for RunConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.