1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Minor improvements to the IPInfo widget display

This commit is contained in:
Chris Cummer 2018-08-03 05:16:43 -07:00
parent 9c3ff8890a
commit 6a7c07eddc
2 changed files with 7 additions and 9 deletions

View File

@ -12,7 +12,7 @@ func (widget *Widget) display(clocks []Clock) {
return
}
str := "\n"
str := ""
for idx, clock := range clocks {
str = str + fmt.Sprintf(
" [%s]%-12s %-10s %7s[white]\n",

View File

@ -78,21 +78,19 @@ func (widget *Widget) ipinfo() {
// read module configs
func (widget *Widget) config() {
nameColor, valueColor := wtf.Config.UString("wtf.mods.ipinfo.colors.name", "red"), wtf.Config.UString("wtf.mods.ipinfo.colors.value", "white")
widget.colors.name = nameColor
widget.colors.value = valueColor
widget.colors.name = wtf.Config.UString("wtf.mods.ipinfo.colors.name", "white")
widget.colors.value = wtf.Config.UString("wtf.mods.ipinfo.colors.value", "white")
}
func (widget *Widget) setResult(info *ipinfo) {
resultTemplate, _ := template.New("ipinfo_result").Parse(
formatableText("IP Address", "Ip") +
formatableText("IP", "Ip") +
formatableText("Hostname", "Hostname") +
formatableText("City", "City") +
formatableText("Region", "Region") +
formatableText("Country", "Country") +
formatableText("Coordinates", "Coordinates") +
formatableText("Postal Code", "PostalCode") +
formatableText("Organization", "Organization"),
formatableText("Coords", "Coordinates") +
formatableText("Org", "Organization"),
)
resultBuffer := new(bytes.Buffer)
@ -114,5 +112,5 @@ func (widget *Widget) setResult(info *ipinfo) {
}
func formatableText(key, value string) string {
return fmt.Sprintf(" [{{.nameColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value)
return fmt.Sprintf(" [{{.nameColor}}]%8s: [{{.valueColor}}]{{.%s}}\n", key, value)
}