mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-27 05:46:34 +02:00
Add spacing around dialog frames
This commit is contained in:
parent
8cd8410ace
commit
3d7f80eebb
3 changed files with 42 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue