Make surrounding whitespace in centeredText the same style

This commit is contained in:
Petar Kapriš 2021-11-30 08:15:07 +01:00 committed by Петар Каприш
parent ce66ae9f21
commit 1a194cc368

View file

@ -74,14 +74,20 @@ func monthHeight(m time.Month) int {
func centeredText(s string, x, y, width int, scr tcell.Screen, style tcell.Style) {
start := x + max((width-utf8.RuneCountInString(s))/2, 0)
i := 0
for ; x+i < start; i++ {
scr.SetContent(x+i, y, ' ', nil, style)
}
for _, char := range s {
if i >= width {
break
}
scr.SetContent(start+i, y, char, nil, style)
scr.SetContent(x+i, y, char, nil, style)
i++
}
for ; x+i < start; i++ {
scr.SetContent(x+i, y, ' ', nil, style)
}
}
func wrappedText(s string, scr tcell.Screen, style tcell.Style) {