Add spacing around dialog frames

This commit is contained in:
patriceckhart 2026-05-22 18:53:23 +02:00
parent 8cd8410ace
commit 3d7f80eebb
3 changed files with 42 additions and 2 deletions

View file

@ -33,6 +33,43 @@ func frameRule(th tui.Theme, width int) string {
return th.FG256(th.Muted, strings.Repeat("─", width))
}
// padDialogFrame inserts breathing room between the shared dialog frame
// chrome and its body while keeping frameHeader/frameRule as single-row
// primitives for callers that need exact row accounting.
func padDialogFrame(lines []string) []string {
if len(lines) == 0 {
return lines
}
out := append([]string(nil), lines...)
if isFrameHeaderLine(out[0]) && (len(out) == 1 || strings.TrimSpace(stripANSIBytes(out[1])) != "") {
out = append(out[:1], append([]string{""}, out[1:]...)...)
}
last := len(out) - 1
if last > 0 && isFrameRuleLine(out[last]) && strings.TrimSpace(stripANSIBytes(out[last-1])) != "" {
out = append(out[:last], append([]string{""}, out[last:]...)...)
}
return out
}
func isFrameHeaderLine(line string) bool {
return strings.HasPrefix(stripANSIBytes(line), "── ")
}
func isFrameRuleLine(line string) bool {
plain := stripANSIBytes(line)
if plain == "" {
return false
}
for _, r := range plain {
if r != '─' {
return false
}
}
return true
}
// frameHeaderColor is like frameHeader but renders in a caller-supplied
// 256-color code. Used by the update-available banner which wants a
// yellow accent on the rules and title.

View file

@ -69,7 +69,7 @@ func renderHelpBlock(th tui.Theme, width int) []string {
}
var out []string
out = append(out, frameHeader(th, "zot help", width))
out = append(out, frameHeader(th, "zot help", width), "")
// commands section
out = append(out, tui.Bold("slash commands:"))
@ -87,6 +87,6 @@ func renderHelpBlock(th tui.Theme, width int) []string {
th.FG256(th.Muted, k[1])))
}
out = append(out, frameRule(th, width), "")
out = append(out, "", frameRule(th, width), "")
return out
}

View file

@ -931,6 +931,9 @@ func (i *Interactive) redraw() {
case i.extPanel.Active():
dialog = i.extPanel.Render(i.cfg.Theme, cols)
}
if len(dialog) > 0 {
dialog = padDialogFrame(dialog)
}
// Slash-command autocomplete: popup above the status line, only
// when the editor starts with "/" and no dialog is already open.