Skip to content

Commit

Permalink
Make width of location dynamic, to accomodate longer labels
Browse files Browse the repository at this point in the history
This addresses wtfutil#1553
  • Loading branch information
Seanstoppable committed Apr 15, 2023
1 parent 1ce1295 commit e42daca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/clocks/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit e42daca

Please sign in to comment.