From e42daca1897deba1ef61c83d091e2235d91149f1 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Sat, 15 Apr 2023 10:14:15 -0500 Subject: [PATCH] Make width of location dynamic, to accomodate longer labels This addresses #1553 --- modules/clocks/display.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/clocks/display.go b/modules/clocks/display.go index ffa986f9f..29ed0dabd 100644 --- a/modules/clocks/display.go +++ b/modules/clocks/display.go @@ -5,13 +5,21 @@ import "fmt" func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) { str := "" + locationWidth := 12 + for _, clock := range clocks { + if len(clock.Label) > locationWidth { + locationWidth = len(clock.Label) + 2 + } + } + if len(clocks) == 0 { str = fmt.Sprintf("\n%s", " no timezone data available") } else { for idx, clock := range clocks { str += fmt.Sprintf( - " [%s]%-12s %-10s %7s[white]\n", + " [%s]%-*s %-10s %7s[white]\n", widget.CommonSettings().RowColor(idx), + locationWidth, clock.Label, clock.Time(timeFormat), clock.Date(dateFormat),