forked from wtfutil/wtf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.go
55 lines (48 loc) · 1.11 KB
/
display.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package toplist
import "fmt"
func (widget *Widget) display() {
str := ""
for _, fromCurrency := range widget.list.items {
str += fmt.Sprintf(
"[%s]%s [%s](%s)\n",
widget.colors.from.displayName,
fromCurrency.displayName,
widget.colors.from.name,
fromCurrency.name,
)
str += makeToListText(fromCurrency.to, widget.colors)
}
widget.Result = str
}
func makeToListText(toList []*tCurrency, colors textColors) string {
str := ""
for _, toCurrency := range toList {
str += makeToText(toCurrency, colors)
}
return str
}
func makeToText(toCurrency *tCurrency, colors textColors) string {
str := ""
str += fmt.Sprintf(" [%s]%s\n", colors.to.name, toCurrency.name)
for _, info := range toCurrency.info {
str += makeInfoText(info, colors)
str += "\n\n"
}
return str
}
func makeInfoText(info tInfo, colors textColors) string {
return fmt.Sprintf(
" [%s]Exchange: [%s]%s\n",
colors.to.field,
colors.to.value,
info.exchange,
) +
fmt.Sprintf(
" [%s]Volume(24h): [%s]%f-[%s]%f",
colors.to.field,
colors.to.value,
info.volume24h,
colors.to.value,
info.volume24hTo,
)
}