Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,25 +962,28 @@ pub fn draw(f: &mut Frame, app: &mut App) {
f.render_widget(gauge, tuner_area);
}

let controls = if is_jp {
vec![
("▶再生", "SPC"),
("▶▶次", "]"),
("◀◀前", "["),
("音量+", "+"),
("音量-", "-"),
("消音", "m"),
("電源", "q"),
// Bolt ⚡ Optimization:
// to avoid heavy allocations (e.g. format!) during the high frequency TUI render loop
// pre-calculate strings containing spaces and brackets here
let controls: &[(&str, &str)] = if is_jp {
&[
(" ▶再生", " [SPC] "),
(" ▶▶次", " []] "),
(" ◀◀前", " [[] "),
(" 音量+", " [+] "),
(" 音量-", " [-] "),
(" 消音", " [m] "),
(" 電源", " [q] "),
]
} else {
vec![
("PLAY", "SPC"),
("SKIP", "]"),
("PREV", "["),
("VOL+", "+"),
("VOL-", "-"),
("MUTE", "m"),
("EXIT", "q"),
&[
(" PLAY", " [SPC] "),
(" SKIP", " []] "),
(" PREV", " [[] "),
(" VOL+", " [+] "),
(" VOL-", " [-] "),
(" MUTE", " [m] "),
(" EXIT", " [q] "),
]
};

Expand All @@ -994,12 +997,12 @@ pub fn draw(f: &mut Frame, app: &mut App) {
if i < btn_layout.len() {
let btn_text = Line::from(vec![
Span::styled(
format!(" {}", label),
*label,
Style::default()
.fg(theme.primary)
.add_modifier(Modifier::BOLD),
),
Span::styled(format!(" [{}] ", key), Style::default().fg(theme.dim)),
Span::styled(*key, Style::default().fg(theme.dim)),
]);

let mut btn_block = Block::default()
Expand Down
Loading