1use ratatui::style::Style;
4use ratatui::text::Span;
5
6#[must_use]
8pub fn hotkey(label: &str) -> Option<char> {
9 let (_, rest) = label.split_once('~')?;
10 rest.split_once('~')?.0.chars().next()
11}
12
13#[must_use]
15pub fn plain(label: &str) -> String {
16 label.replace('~', "")
17}
18
19pub(crate) fn spans(label: &str, base: Style, hot: Style) -> Vec<Span<'static>> {
21 let mut spans = Vec::new();
22 for (index, part) in label.split('~').enumerate() {
23 if !part.is_empty() {
24 let style = if index % 2 == 1 { hot } else { base };
25 spans.push(Span::styled(part.to_string(), style));
26 }
27 }
28 spans
29}
30
31#[cfg(test)]
32mod tests;