pub struct KeybindingHints { /* private fields */ }Expand description
A keybinding hints widget with category grouping and context-aware filtering.
Supports two entry scopes:
- Global: shortcuts always visible regardless of context.
- Contextual: shortcuts shown only when
show_contextis enabled (typically when a particular widget has focus).
In HelpMode::Full mode with categories enabled, entries are grouped
under category headers. In HelpMode::Short mode, entries are rendered
inline.
§Example
use ftui_widgets::help::{KeybindingHints, HelpCategory, KeyFormat};
let hints = KeybindingHints::new()
.with_key_format(KeyFormat::Bracketed)
.global_entry("q", "quit")
.global_entry_categorized("Tab", "next", HelpCategory::Navigation)
.contextual_entry_categorized("^s", "save", HelpCategory::File);
assert_eq!(hints.global_entries().len(), 2);
assert_eq!(hints.contextual_entries().len(), 1);Implementations§
Source§impl KeybindingHints
impl KeybindingHints
Sourcepub fn global_entry(
self,
key: impl Into<String>,
desc: impl Into<String>,
) -> Self
pub fn global_entry( self, key: impl Into<String>, desc: impl Into<String>, ) -> Self
Add a global entry (always visible).
Sourcepub fn global_entry_categorized(
self,
key: impl Into<String>,
desc: impl Into<String>,
category: HelpCategory,
) -> Self
pub fn global_entry_categorized( self, key: impl Into<String>, desc: impl Into<String>, category: HelpCategory, ) -> Self
Add a global entry with a specific category.
Sourcepub fn contextual_entry(
self,
key: impl Into<String>,
desc: impl Into<String>,
) -> Self
pub fn contextual_entry( self, key: impl Into<String>, desc: impl Into<String>, ) -> Self
Add a contextual entry (shown when context is active).
Sourcepub fn contextual_entry_categorized(
self,
key: impl Into<String>,
desc: impl Into<String>,
category: HelpCategory,
) -> Self
pub fn contextual_entry_categorized( self, key: impl Into<String>, desc: impl Into<String>, category: HelpCategory, ) -> Self
Add a contextual entry with a specific category.
Sourcepub fn with_global_entry(self, entry: HelpEntry) -> Self
pub fn with_global_entry(self, entry: HelpEntry) -> Self
Add a pre-built global entry.
Sourcepub fn with_contextual_entry(self, entry: HelpEntry) -> Self
pub fn with_contextual_entry(self, entry: HelpEntry) -> Self
Add a pre-built contextual entry.
Sourcepub fn with_key_format(self, format: KeyFormat) -> Self
pub fn with_key_format(self, format: KeyFormat) -> Self
Set the key display format.
Sourcepub fn with_show_context(self, show: bool) -> Self
pub fn with_show_context(self, show: bool) -> Self
Set whether contextual entries are shown.
Sourcepub fn with_show_categories(self, show: bool) -> Self
pub fn with_show_categories(self, show: bool) -> Self
Set whether category headers are shown in full mode.
Sourcepub fn with_key_style(self, style: Style) -> Self
pub fn with_key_style(self, style: Style) -> Self
Set the style for key text.
Sourcepub fn with_desc_style(self, style: Style) -> Self
pub fn with_desc_style(self, style: Style) -> Self
Set the style for description text.
Sourcepub fn with_separator_style(self, style: Style) -> Self
pub fn with_separator_style(self, style: Style) -> Self
Set the style for separators.
Sourcepub fn with_category_style(self, style: Style) -> Self
pub fn with_category_style(self, style: Style) -> Self
Set the style for category headers.
Sourcepub fn with_separator(self, sep: impl Into<String>) -> Self
pub fn with_separator(self, sep: impl Into<String>) -> Self
Set the separator string for short mode.
Sourcepub fn global_entries(&self) -> &[HelpEntry]
pub fn global_entries(&self) -> &[HelpEntry]
Get the global entries.
Sourcepub fn contextual_entries(&self) -> &[HelpEntry]
pub fn contextual_entries(&self) -> &[HelpEntry]
Get the contextual entries.
Sourcepub fn key_format(&self) -> KeyFormat
pub fn key_format(&self) -> KeyFormat
Get the key format.
Sourcepub fn toggle_mode(&mut self)
pub fn toggle_mode(&mut self)
Toggle between short and full mode.
Sourcepub fn set_show_context(&mut self, show: bool)
pub fn set_show_context(&mut self, show: bool)
Set whether contextual entries are shown (mutable).
Sourcepub fn visible_entries(&self) -> Vec<HelpEntry>
pub fn visible_entries(&self) -> Vec<HelpEntry>
Collect visible entries, applying scope filter and key formatting.
Trait Implementations§
Source§impl Clone for KeybindingHints
impl Clone for KeybindingHints
Source§fn clone(&self) -> KeybindingHints
fn clone(&self) -> KeybindingHints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more