/
display.go
60 lines (52 loc) · 1.24 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
56
57
58
59
60
package toplist
import "fmt"
func (widget *Widget) display() {
str := ""
for _, fromCurrency := range widget.list.items {
str += fmt.Sprintf(
"[%s]%s [%s](%s)\n",
widget.settings.colors.from.displayName,
fromCurrency.displayName,
widget.settings.colors.from.name,
fromCurrency.name,
)
str += widget.makeToListText(fromCurrency.to)
}
widget.Result = str
}
func (widget *Widget) makeToListText(toList []*tCurrency) string {
str := ""
for _, toCurrency := range toList {
str += widget.makeToText(toCurrency)
}
return str
}
func (widget *Widget) makeToText(toCurrency *tCurrency) string {
str := ""
str += fmt.Sprintf(
" [%s]%s\n",
widget.settings.colors.to.name,
toCurrency.name,
)
for _, info := range toCurrency.info {
str += widget.makeInfoText(info)
str += "\n\n"
}
return str
}
func (widget *Widget) makeInfoText(info tInfo) string {
return fmt.Sprintf(
" [%s]Exchange: [%s]%s\n",
widget.settings.colors.top.to.field,
widget.settings.colors.top.to.value,
info.exchange,
) +
fmt.Sprintf(
" [%s]Volume(24h): [%s]%f-[%s]%f",
widget.settings.colors.top.to.field,
widget.settings.colors.top.to.value,
info.volume24h,
widget.settings.colors.top.to.value,
info.volume24hTo,
)
}