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:
parent
9c3ff8890a
commit
6a7c07eddc
@ -12,7 +12,7 @@ func (widget *Widget) display(clocks []Clock) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
str := "\n"
|
str := ""
|
||||||
for idx, clock := range clocks {
|
for idx, clock := range clocks {
|
||||||
str = str + fmt.Sprintf(
|
str = str + fmt.Sprintf(
|
||||||
" [%s]%-12s %-10s %7s[white]\n",
|
" [%s]%-12s %-10s %7s[white]\n",
|
||||||
|
@ -78,21 +78,19 @@ func (widget *Widget) ipinfo() {
|
|||||||
|
|
||||||
// read module configs
|
// read module configs
|
||||||
func (widget *Widget) config() {
|
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 = wtf.Config.UString("wtf.mods.ipinfo.colors.name", "white")
|
||||||
widget.colors.name = nameColor
|
widget.colors.value = wtf.Config.UString("wtf.mods.ipinfo.colors.value", "white")
|
||||||
widget.colors.value = valueColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) setResult(info *ipinfo) {
|
func (widget *Widget) setResult(info *ipinfo) {
|
||||||
resultTemplate, _ := template.New("ipinfo_result").Parse(
|
resultTemplate, _ := template.New("ipinfo_result").Parse(
|
||||||
formatableText("IP Address", "Ip") +
|
formatableText("IP", "Ip") +
|
||||||
formatableText("Hostname", "Hostname") +
|
formatableText("Hostname", "Hostname") +
|
||||||
formatableText("City", "City") +
|
formatableText("City", "City") +
|
||||||
formatableText("Region", "Region") +
|
formatableText("Region", "Region") +
|
||||||
formatableText("Country", "Country") +
|
formatableText("Country", "Country") +
|
||||||
formatableText("Coordinates", "Coordinates") +
|
formatableText("Coords", "Coordinates") +
|
||||||
formatableText("Postal Code", "PostalCode") +
|
formatableText("Org", "Organization"),
|
||||||
formatableText("Organization", "Organization"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
resultBuffer := new(bytes.Buffer)
|
resultBuffer := new(bytes.Buffer)
|
||||||
@ -114,5 +112,5 @@ func (widget *Widget) setResult(info *ipinfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func formatableText(key, value string) string {
|
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)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user