Add function wrappedText

This commit is contained in:
Petar Kapriš 2021-08-25 18:33:47 +02:00 committed by Петар Каприш
parent 593900c788
commit 357757e479

17
Main.go
View file

@ -67,6 +67,23 @@ func centeredText(s string, x, y, width int, scr tcell.Screen, style tcell.Style
}
}
func wrappedText(s string, scr tcell.Screen, style tcell.Style) {
x := 0
y := 0
w, h := scr.Size()
for _, char := range s {
if x >= w {
if y >= h {
break;
}
x = 0
y++
}
scr.SetContent(x, y, char, nil, style)
x++
}
}
func drawMonth(m time.Month, x, y int) {
centeredText(months[m], x, y, monthWidth, wall, defStyle)