Wrap overlay text instead of cutting it; the project check is a regression check, renamed check.sh; concrete Headroom steps; Mouse-1 measured

This commit is contained in:
Sam
2026-11-11 16:35:44 +11:00
parent c50c1efa22
commit 70e1f55486
7 changed files with 150 additions and 56 deletions

View File

@@ -278,15 +278,47 @@ func wrap(s string, w int) []string {
// 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{""}
// The box is as wide as the screen allows, and every line of text is wrapped
// inside it. Cutting a sentence in half hides the reason a key exists.
boxW := min(92, max(40, w-6))
if boxW > w {
boxW = w
}
keyCol := 16
inner := boxW - 4 - keyCol
if inner < 20 {
keyCol = 8
inner = boxW - 4 - keyCol
}
var lines []string
lines = append(lines, "")
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]))
key := e[0]
if key == "" {
for _, cont := range wrap(e[1], max(12, inner)) {
lines = append(lines, " "+strings.Repeat(" ", keyCol)+
lipgloss.NewStyle().Foreground(lipgloss.Color(active.Text)).Render(cont))
}
continue
}
wrapped := wrap(e[1], max(12, inner))
styled := lipgloss.NewStyle().Foreground(lipgloss.Color(active.Accent)).Bold(true).
Render(padTo(key, keyCol))
text := lipgloss.NewStyle().Foreground(lipgloss.Color(active.Text)).Render(wrapped[0])
lines = append(lines, " "+styled+text)
for _, cont := range wrapped[1:] {
lines = append(lines, " "+strings.Repeat(" ", keyCol)+
lipgloss.NewStyle().Foreground(lipgloss.Color(active.Text)).Render(cont))
}
}
lines = append(lines, "", dimStyle().Render(" esc or ? closes this"))
boxH := len(lines) + 2
if boxH > h-2 {
boxH = h - 2
lines = lines[:max(1, boxH-2)]
}
p := panel{title: title, width: boxW, height: boxH, focused: true}
return lipgloss.Place(w, h, lipgloss.Center, lipgloss.Center, p.render(lines))
}