Feat: ability to rename steps

This commit is contained in:
2026-01-30 11:58:16 +01:00
parent d25b1317fc
commit 77a6aa9eb7
9 changed files with 149 additions and 12 deletions

View File

@@ -184,19 +184,63 @@ fn render_tile(
(false, false, false, _, _) => (Color::Rgb(45, 48, 55), Color::Rgb(120, 125, 135)),
};
let source_idx = step.and_then(|s| s.source);
let symbol = if is_playing {
"".to_string()
} else if let Some(source) = step.and_then(|s| s.source) {
} else if let Some(source) = source_idx {
format!("{:02}", source + 1)
} else {
format!("{:02}", step_idx + 1)
};
let tile = Paragraph::new(symbol)
.alignment(Alignment::Center)
.style(Style::new().bg(bg).fg(fg).add_modifier(Modifier::BOLD));
// For linked steps, get the name from the source step
let step_name = if let Some(src) = source_idx {
pattern.step(src).and_then(|s| s.name.as_ref())
} else {
step.and_then(|s| s.name.as_ref())
};
let num_lines = if step_name.is_some() { 2u16 } else { 1u16 };
let content_height = num_lines;
let y_offset = area.height.saturating_sub(content_height) / 2;
frame.render_widget(tile, area);
// Fill background for entire tile
let bg_fill = Paragraph::new("").style(Style::new().bg(bg));
frame.render_widget(bg_fill, area);
if let Some(name) = step_name {
let name_area = Rect {
x: area.x,
y: area.y + y_offset,
width: area.width,
height: 1,
};
let name_widget = Paragraph::new(name.as_str())
.alignment(Alignment::Center)
.style(Style::new().bg(bg).fg(fg).add_modifier(Modifier::BOLD));
frame.render_widget(name_widget, name_area);
let symbol_area = Rect {
x: area.x,
y: area.y + y_offset + 1,
width: area.width,
height: 1,
};
let symbol_widget = Paragraph::new(symbol)
.alignment(Alignment::Center)
.style(Style::new().bg(bg).fg(fg).add_modifier(Modifier::BOLD));
frame.render_widget(symbol_widget, symbol_area);
} else {
let centered_area = Rect {
x: area.x,
y: area.y + y_offset,
width: area.width,
height: 1,
};
let tile = Paragraph::new(symbol)
.alignment(Alignment::Center)
.style(Style::new().bg(bg).fg(fg).add_modifier(Modifier::BOLD));
frame.render_widget(tile, centered_area);
}
}
fn render_scope(frame: &mut Frame, app: &App, area: Rect) {