github.com/wtfutil/wtf@v0.43.0/modules/digitalclock/display.go (about)

     1  package digitalclock
     2  
     3  import "strings"
     4  
     5  func mergeLines(outString []string) string {
     6  	return strings.Join(outString, "\n")
     7  }
     8  
     9  func renderWidget(widgetSettings Settings) string {
    10  	outputStrings := []string{}
    11  
    12  	clockString, needBorder := renderClock(widgetSettings)
    13  	if needBorder {
    14  		outputStrings = append(outputStrings, mergeLines([]string{"", clockString, ""}))
    15  	} else {
    16  		outputStrings = append(outputStrings, clockString)
    17  	}
    18  
    19  	if widgetSettings.withDate {
    20  		outputStrings = append(outputStrings, getDate(widgetSettings.dateFormat, widgetSettings.withDatePrefix), getUTC(), getEpoch())
    21  	}
    22  
    23  	return mergeLines(outputStrings)
    24  }
    25  
    26  func (widget *Widget) display() {
    27  	widget.Redraw(func() (string, string, bool) {
    28  		return widget.CommonSettings().Title, renderWidget(*widget.settings), false
    29  	})
    30  }