mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Clean up the formatting of the text in Bittrex module
This commit is contained in:
parent
57e3a01b3a
commit
71df0c59e0
@ -22,20 +22,22 @@ func summaryText(list *summaryList, colors *TextColors) string {
|
|||||||
str := ""
|
str := ""
|
||||||
|
|
||||||
for _, baseCurrency := range list.items {
|
for _, baseCurrency := range list.items {
|
||||||
str += fmt.Sprintf("[%s]%s[%s](%s):\n", colors.base.displayName, baseCurrency.displayName, colors.base.name, baseCurrency.name)
|
str += fmt.Sprintf(" [%s]%s[%s] (%s)\n\n", colors.base.displayName, baseCurrency.displayName, colors.base.name, baseCurrency.name)
|
||||||
|
|
||||||
resultTemplate := template.New("bittrex")
|
resultTemplate := template.New("bittrex")
|
||||||
|
|
||||||
for _, marketCurrency := range baseCurrency.markets {
|
for _, marketCurrency := range baseCurrency.markets {
|
||||||
writer := new(bytes.Buffer)
|
writer := new(bytes.Buffer)
|
||||||
|
|
||||||
strTemplate, _ := resultTemplate.Parse(
|
strTemplate, _ := resultTemplate.Parse(
|
||||||
"\t[{{.nameColor}}]{{.mName}}\n" +
|
" [{{.nameColor}}]{{.mName}}\n" +
|
||||||
formatableText("High", "High") +
|
formatableText("High", "High") +
|
||||||
formatableText("Low", "Low") +
|
formatableText("Low", "Low") +
|
||||||
formatableText("Last", "Last") +
|
formatableText("Last", "Last") +
|
||||||
formatableText("Volume", "Volume") +
|
formatableText("Volume", "Volume") +
|
||||||
formatableText("OpenSellOrders", "OpenSellOrders") +
|
"\n" +
|
||||||
formatableText("OpenBuyOrders", "OpenBuyOrders"),
|
formatableText("Open Buy", "OpenBuyOrders") +
|
||||||
|
formatableText("Open Sell", "OpenSellOrders"),
|
||||||
)
|
)
|
||||||
|
|
||||||
strTemplate.Execute(writer, map[string]string{
|
strTemplate.Execute(writer, map[string]string{
|
||||||
@ -47,11 +49,11 @@ func summaryText(list *summaryList, colors *TextColors) string {
|
|||||||
"Low": marketCurrency.Low,
|
"Low": marketCurrency.Low,
|
||||||
"Last": marketCurrency.Last,
|
"Last": marketCurrency.Last,
|
||||||
"Volume": marketCurrency.Volume,
|
"Volume": marketCurrency.Volume,
|
||||||
"OpenSellOrders": marketCurrency.OpenSellOrders,
|
|
||||||
"OpenBuyOrders": marketCurrency.OpenBuyOrders,
|
"OpenBuyOrders": marketCurrency.OpenBuyOrders,
|
||||||
|
"OpenSellOrders": marketCurrency.OpenSellOrders,
|
||||||
})
|
})
|
||||||
|
|
||||||
str += writer.String()
|
str += writer.String() + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -61,5 +63,5 @@ func summaryText(list *summaryList, colors *TextColors) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func formatableText(key, value string) string {
|
func formatableText(key, value string) string {
|
||||||
return fmt.Sprintf("\t\t[{{.fieldColor}}]%s: [{{.valueColor}}]{{.%s}}\n", key, value)
|
return fmt.Sprintf("[{{.fieldColor}}]%12s: [{{.valueColor}}]{{.%s}}\n", key, value)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ type Widget struct {
|
|||||||
func NewWidget() *Widget {
|
func NewWidget() *Widget {
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" $ Bittrex ", "bittrex", false),
|
TextWidget: wtf.NewTextWidget(" Bittrex ", "bittrex", false),
|
||||||
summaryList: summaryList{},
|
summaryList: summaryList{},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,12 +88,12 @@ func makeMarketCurrency(name string) *mCurrency {
|
|||||||
return &mCurrency{
|
return &mCurrency{
|
||||||
name: name,
|
name: name,
|
||||||
summaryInfo: summaryInfo{
|
summaryInfo: summaryInfo{
|
||||||
High: "-1",
|
High: "",
|
||||||
Low: "-1",
|
Low: "",
|
||||||
Volume: "-1",
|
Volume: "",
|
||||||
Last: "-1",
|
Last: "",
|
||||||
OpenBuyOrders: "-1",
|
OpenBuyOrders: "",
|
||||||
OpenSellOrders: "-1",
|
OpenSellOrders: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user