mirror of
https://github.com/anotherhadi/default-creds-tui.git
synced 2026-10-05 19:08:25 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
625f494623 |
+14
-4
@@ -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")))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user