Help on every panel, task filter, unblock key, mouse zones, safe add-only rebuild
This commit is contained in:
17
tui/frame.go
17
tui/frame.go
@@ -272,3 +272,20 @@ func wrap(s string, w int) []string {
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
||||
// helpOverlay draws the keys for the panel that asked for it, centred over the
|
||||
// screen. It replaces the whole view rather than floating over it, so nothing
|
||||
// behind it can be misread as still active.
|
||||
func helpOverlay(title string, entries [][2]string, w, h int) string {
|
||||
boxW := min(64, max(30, w-8))
|
||||
boxH := min(len(entries)+4, max(8, h-4))
|
||||
lines := []string{""}
|
||||
for _, e := range entries {
|
||||
key := lipgloss.NewStyle().Foreground(lipgloss.Color(active.Accent)).Bold(true).
|
||||
Width(16).Render(e[0])
|
||||
lines = append(lines, " "+key+lipgloss.NewStyle().Foreground(lipgloss.Color(active.Text)).Render(e[1]))
|
||||
}
|
||||
lines = append(lines, "", dimStyle().Render(" esc or ? closes this"))
|
||||
p := panel{title: title, width: boxW, height: boxH, focused: true}
|
||||
return lipgloss.Place(w, h, lipgloss.Center, lipgloss.Center, p.render(lines))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user