Skip to main content

ActionConfig

Struct ActionConfig 

Source
pub struct ActionConfig {
    pub sequence_config: SequenceConfig,
    pub ctrl_c_idle_action: CtrlCIdleAction,
}
Expand description

Configuration for action mapping behavior.

This struct combines sequence detection settings with keybinding behavior configuration. It controls how keys like Ctrl+C, Ctrl+D, Esc, and Esc Esc are interpreted based on application state.

§Environment Variables

VariableTypeDefaultDescription
FTUI_CTRL_C_IDLE_ACTIONstring“quit”Action when Ctrl+C in idle state
FTUI_ESC_SEQ_TIMEOUT_MSu64250Esc Esc detection window
FTUI_ESC_DEBOUNCE_MSu6450Minimum Esc wait
FTUI_DISABLE_ESC_SEQboolfalseDisable Esc Esc sequences

§Example: Configure via environment

# Make Ctrl+C do nothing when idle (instead of quit)
export FTUI_CTRL_C_IDLE_ACTION=noop

# Or make it beep
export FTUI_CTRL_C_IDLE_ACTION=bell

# Faster double-Esc detection
export FTUI_ESC_SEQ_TIMEOUT_MS=200

§Example: Configure in code

use ftui_core::keybinding::{ActionConfig, CtrlCIdleAction, SequenceConfig};
use std::time::Duration;

let config = ActionConfig::default()
    .with_ctrl_c_idle(CtrlCIdleAction::Bell)
    .with_sequence_config(
        SequenceConfig::default()
            .with_timeout(Duration::from_millis(200))
    );

Fields§

§sequence_config: SequenceConfig

Sequence detection configuration (timeouts, debounce, disable flag).

§ctrl_c_idle_action: CtrlCIdleAction

Action when Ctrl+C pressed with empty input and no task.

  • Quit (default): Exit the application
  • Noop: Do nothing
  • Bell: Emit terminal bell

Implementations§

Source§

impl ActionConfig

Source

pub fn with_sequence_config(self, config: SequenceConfig) -> Self

Create config with custom sequence settings.

Source

pub fn with_ctrl_c_idle(self, action: CtrlCIdleAction) -> Self

Set Ctrl+C idle action.

Source

pub fn from_env() -> Self

Load config from environment variables.

Reads:

  • FTUI_CTRL_C_IDLE_ACTION: “quit”, “noop”, or “bell”
  • Plus all environment variables from SequenceConfig::from_env
Source

pub fn validated(self) -> Self

Validate and return a config with clamped sequence values.

Delegates to SequenceConfig::validated for timing bounds.

Trait Implementations§

Source§

impl Clone for ActionConfig

Source§

fn clone(&self) -> ActionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActionConfig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.