1 Commits
Author SHA1 Message Date
Hadi 625f494623 fix: Items take full width for bubblezone to work everywhere
Signed-off-by: Hadi <[email protected]>
2026-08-27 13:31:09 +02:00
+14 -4
View File
@@ -27,6 +27,16 @@ func clampToWidth(s string, width int) string {
return ansi.Truncate(s, width, "…") return ansi.Truncate(s, width, "…")
} }
func padToWidth(s string, width int) string {
if width <= 0 {
return s
}
if w := ansi.StringWidth(s); w < width {
s += strings.Repeat(" ", width-w)
}
return s
}
type entryDelegate struct{} type entryDelegate struct{}
func (d entryDelegate) Height() int { return cardHeight } func (d entryDelegate) Height() int { return cardHeight }
@@ -76,10 +86,10 @@ func (d entryDelegate) Render(w io.Writer, m list.Model, index int, item list.It
} }
lines := []string{ lines := []string{
clampToWidth(side.Render(line1), width), padToWidth(clampToWidth(side.Render(line1), width), width),
clampToWidth(side.Render(line2), width), padToWidth(clampToWidth(side.Render(line2), width), width),
clampToWidth(side.Render(line3), width), padToWidth(clampToWidth(side.Render(line3), width), width),
clampToWidth(side.Render(line4), width), padToWidth(clampToWidth(side.Render(line4), width), width),
} }
fmt.Fprint(w, zone.Mark(entryZoneID(index), strings.Join(lines, "\n"))) fmt.Fprint(w, zone.Mark(entryZoneID(index), strings.Join(lines, "\n")))
} }