KeyMap

Trait KeyMap 

Source
pub trait KeyMap {
    // Required methods
    fn short_help(&self) -> Vec<&Binding>;
    fn full_help(&self) -> Vec<Vec<&Binding>>;
}
Expand description

KeyMap trait for components that provide help information.

This trait should be implemented by any component that wants to provide contextual help information through the help component. It matches the Go implementation’s KeyMap interface.

§Examples

use bubbletea_widgets::key::{KeyMap, Binding};
use crossterm::event::KeyCode;

struct MyComponent {
    save: Binding,
    quit: Binding,
}

impl KeyMap for MyComponent {
    fn short_help(&self) -> Vec<&Binding> {
        vec![&self.save, &self.quit]
    }

    fn full_help(&self) -> Vec<Vec<&Binding>> {
        vec![
            vec![&self.save],    // File operations column
            vec![&self.quit],    // Application column
        ]
    }
}

Required Methods§

Source

fn short_help(&self) -> Vec<&Binding>

Returns a slice of bindings to be displayed in the short version of help.

This should return the most important or commonly used key bindings that will fit on a single line.

Source

fn full_help(&self) -> Vec<Vec<&Binding>>

Returns an extended group of help items, grouped by columns.

Each inner vector represents a column of related key bindings. This allows for organized display of comprehensive help information.

Implementors§

Source§

impl KeyMap for FilepickerKeyMap

Source§

impl KeyMap for ListKeyMap

Source§

impl KeyMap for PaginatorKeyMap

Source§

impl KeyMap for TableKeyMap

Source§

impl KeyMap for TextareaKeyMap

Implementation of KeyMap trait for help integration

Source§

impl KeyMap for ViewportKeyMap