Make surrounding whitespace in centeredText the same style
This commit is contained in:
parent
ce66ae9f21
commit
1a194cc368
8
Main.go
8
Main.go
|
@ -74,14 +74,20 @@ func monthHeight(m time.Month) int {
|
||||||
func centeredText(s string, x, y, width int, scr tcell.Screen, style tcell.Style) {
|
func centeredText(s string, x, y, width int, scr tcell.Screen, style tcell.Style) {
|
||||||
start := x + max((width-utf8.RuneCountInString(s))/2, 0)
|
start := x + max((width-utf8.RuneCountInString(s))/2, 0)
|
||||||
i := 0
|
i := 0
|
||||||
|
for ; x+i < start; i++ {
|
||||||
|
scr.SetContent(x+i, y, ' ', nil, style)
|
||||||
|
}
|
||||||
for _, char := range s {
|
for _, char := range s {
|
||||||
if i >= width {
|
if i >= width {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
scr.SetContent(start+i, y, char, nil, style)
|
scr.SetContent(x+i, y, char, nil, style)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
for ; x+i < start; i++ {
|
||||||
|
scr.SetContent(x+i, y, ' ', nil, style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrappedText(s string, scr tcell.Screen, style tcell.Style) {
|
func wrappedText(s string, scr tcell.Screen, style tcell.Style) {
|
||||||
|
|
Loading…
Reference in a new issue