KeyBindings

Struct KeyBindings 

Source
pub struct KeyBindings {
Show 18 fields pub move_up: Vec<KeyCombo>, pub move_down: Vec<KeyCombo>, pub move_left: Vec<KeyCombo>, pub move_right: Vec<KeyCombo>, pub move_line_start: Vec<KeyCombo>, pub move_line_end: Vec<KeyCombo>, pub delete_char_before: Vec<KeyCombo>, pub delete_char_at: Vec<KeyCombo>, pub kill_line: Vec<KeyCombo>, pub insert_newline: Vec<KeyCombo>, pub submit: Vec<KeyCombo>, pub interrupt: Vec<KeyCombo>, pub quit: Vec<KeyCombo>, pub force_quit: Vec<KeyCombo>, pub enter_exit_mode: Vec<KeyCombo>, pub exit_timeout_secs: u64, pub select: Vec<KeyCombo>, pub cancel: Vec<KeyCombo>,
}
Expand description

Key binding configuration.

Specifies which key combinations trigger which actions. Multiple key combinations can be assigned to the same action.

The default is bare_minimum() which only provides basic functionality. Apps should explicitly choose their bindings:

  • emacs() for full Emacs-style bindings
  • minimal() for simple arrow-key navigation

Fields§

§move_up: Vec<KeyCombo>

Move cursor up.

§move_down: Vec<KeyCombo>

Move cursor down.

§move_left: Vec<KeyCombo>

Move cursor left.

§move_right: Vec<KeyCombo>

Move cursor right.

§move_line_start: Vec<KeyCombo>

Move to line start.

§move_line_end: Vec<KeyCombo>

Move to line end.

§delete_char_before: Vec<KeyCombo>

Delete char before cursor.

§delete_char_at: Vec<KeyCombo>

Delete char at cursor.

§kill_line: Vec<KeyCombo>

Kill to end of line.

§insert_newline: Vec<KeyCombo>

Insert newline in multi-line input.

§submit: Vec<KeyCombo>

Submit message.

§interrupt: Vec<KeyCombo>

Interrupt current request.

§quit: Vec<KeyCombo>

Quit immediately (only when input empty and no modal is blocking).

§force_quit: Vec<KeyCombo>

Force quit (works even in modals).

§enter_exit_mode: Vec<KeyCombo>

Enter exit confirmation mode (requires pressing twice to exit).

§exit_timeout_secs: u64

Timeout in seconds for exit confirmation mode.

§select: Vec<KeyCombo>

Select/confirm in widgets (Enter, Space).

§cancel: Vec<KeyCombo>

Cancel/close in widgets (Esc).

Implementations§

Source§

impl KeyBindings

Source

pub fn bare_minimum() -> Self

Bare minimum bindings - only Esc to quit.

This is the default when no bindings are specified. Apps should explicitly choose their bindings (e.g., emacs() or minimal()).

Only provides:

  • Esc to quit (when input is empty)
  • Ctrl+Q force quit (always works)
  • Enter to submit
  • Backspace/Delete for basic editing
  • Arrow keys for navigation
Source

pub fn emacs() -> Self

Emacs-style bindings.

Full-featured bindings for power users:

  • Ctrl+P/N/B/F for navigation
  • Ctrl+A/E for line start/end
  • Ctrl+K to kill line
  • Ctrl+D for exit mode (or delete char if not empty)
  • Esc to interrupt
Source

pub fn minimal() -> Self

Minimal bindings (arrows only, Esc to quit).

This is simpler for users unfamiliar with Emacs:

  • Arrow keys only for navigation
  • Esc quits (when input empty and no modal)
  • No Ctrl key requirements for basic use
Source

pub fn with_move_up(self, combos: Vec<KeyCombo>) -> Self

Set the move up key bindings.

Source

pub fn with_move_down(self, combos: Vec<KeyCombo>) -> Self

Set the move down key bindings.

Source

pub fn with_move_left(self, combos: Vec<KeyCombo>) -> Self

Set the move left key bindings.

Source

pub fn with_move_right(self, combos: Vec<KeyCombo>) -> Self

Set the move right key bindings.

Source

pub fn with_move_line_start(self, combos: Vec<KeyCombo>) -> Self

Set the move to line start key bindings.

Source

pub fn with_move_line_end(self, combos: Vec<KeyCombo>) -> Self

Set the move to line end key bindings.

Source

pub fn with_delete_char_before(self, combos: Vec<KeyCombo>) -> Self

Set the delete char before (backspace) key bindings.

Source

pub fn with_delete_char_at(self, combos: Vec<KeyCombo>) -> Self

Set the delete char at (delete) key bindings.

Source

pub fn with_kill_line(self, combos: Vec<KeyCombo>) -> Self

Set the kill line key bindings.

Source

pub fn with_insert_newline(self, combos: Vec<KeyCombo>) -> Self

Set the insert newline key bindings.

Source

pub fn with_submit(self, combos: Vec<KeyCombo>) -> Self

Set the submit key bindings.

Source

pub fn with_interrupt(self, combos: Vec<KeyCombo>) -> Self

Set the interrupt key bindings.

Source

pub fn with_quit(self, combos: Vec<KeyCombo>) -> Self

Set the quit key bindings.

Source

pub fn with_force_quit(self, combos: Vec<KeyCombo>) -> Self

Set the force quit key bindings.

Source

pub fn with_enter_exit_mode(self, combos: Vec<KeyCombo>) -> Self

Set the enter exit mode key bindings.

Source

pub fn with_exit_timeout_secs(self, secs: u64) -> Self

Set the exit timeout in seconds.

Source

pub fn with_select(self, combos: Vec<KeyCombo>) -> Self

Set the select key bindings (for widget selection).

Source

pub fn with_cancel(self, combos: Vec<KeyCombo>) -> Self

Set the cancel key bindings (for widget cancellation).

Source

pub fn without_exit_mode(self) -> Self

Disable exit mode (sets enter_exit_mode to empty).

Source

pub fn without_quit(self) -> Self

Disable quit binding (sets quit to empty).

Source

pub fn without_force_quit(self) -> Self

Disable force quit binding (sets force_quit to empty).

Source

pub fn without_interrupt(self) -> Self

Disable interrupt binding (sets interrupt to empty).

Source

pub fn without_kill_line(self) -> Self

Disable kill line binding (sets kill_line to empty).

Source

pub fn without_insert_newline(self) -> Self

Disable insert newline binding (sets insert_newline to empty).

Source

pub fn add_move_up(self, combo: KeyCombo) -> Self

Add a key combo to the move up bindings.

Source

pub fn add_move_down(self, combo: KeyCombo) -> Self

Add a key combo to the move down bindings.

Source

pub fn add_move_left(self, combo: KeyCombo) -> Self

Add a key combo to the move left bindings.

Source

pub fn add_move_right(self, combo: KeyCombo) -> Self

Add a key combo to the move right bindings.

Source

pub fn add_quit(self, combo: KeyCombo) -> Self

Add a key combo to the quit bindings.

Source

pub fn add_submit(self, combo: KeyCombo) -> Self

Add a key combo to the submit bindings.

Source

pub fn add_interrupt(self, combo: KeyCombo) -> Self

Add a key combo to the interrupt bindings.

Source

pub fn add_enter_exit_mode(self, combo: KeyCombo) -> Self

Add a key combo to the enter exit mode bindings.

Source

pub fn add_force_quit(self, combo: KeyCombo) -> Self

Add a key combo to the force quit bindings.

Source

pub fn add_select(self, combo: KeyCombo) -> Self

Add a key combo to the select bindings.

Source

pub fn add_cancel(self, combo: KeyCombo) -> Self

Add a key combo to the cancel bindings.

Trait Implementations§

Source§

impl Clone for KeyBindings

Source§

fn clone(&self) -> KeyBindings

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 KeyBindings

Source§

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

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

impl Default for KeyBindings

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more