From 1a194cc368db3af5fe47d260b7a0ba1376cc3e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Kapri=C5=A1?= Date: Tue, 30 Nov 2021 08:15:07 +0100 Subject: [PATCH] Make surrounding whitespace in centeredText the same style --- Main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Main.go b/Main.go index e7a7521..8a87602 100644 --- a/Main.go +++ b/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) { 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) {