fix chart resize

pull/15/head
Miguel Mota 6 years ago
parent 921f1143bb
commit 488dd12f51

@ -13,23 +13,25 @@ import (
var oneWeek = (time.Hour * 24) * 7
func (ct *Cointop) updateChart() error {
maxX := ct.width()
if maxX > ct.maxtablewidth {
maxX = ct.maxtablewidth
}
maxX := ct.maxtablewidth - 3
coin := ct.selectedCoinName()
ct.chartPoints(maxX, coin)
if len(ct.chartpoints) != 0 {
ct.chartview.Clear()
}
var body string
for i := range ct.chartpoints {
var s string
for j := range ct.chartpoints[i] {
p := ct.chartpoints[i][j]
s = fmt.Sprintf("%s%c", s, p.Ch)
}
fmt.Fprintln(ct.chartview, color.White(s))
body = fmt.Sprintf("%s%s\n", body, s)
}
ct.update(func() {
fmt.Fprint(ct.chartview, color.White(body))
})
return nil
}

@ -59,17 +59,18 @@ func (ct *Cointop) refreshTable() error {
}
name := coin.Name
dots := "..."
star := " "
if coin.Favorite {
dots = "..*"
name = fmt.Sprintf("%s*", name)
star = "*"
}
rank := fmt.Sprintf("%s%v", color.Yellow(star), color.White(fmt.Sprintf("%6v ", coin.Rank)))
lastchar := len(name)
if lastchar > 20 {
lastchar = 20
name = fmt.Sprintf("%s%s", name[0:18], dots)
}
ct.table.AddRow(
color.White(fmt.Sprintf("%7v ", coin.Rank)),
rank,
namecolor(fmt.Sprintf("%.22s", name)),
color.White(fmt.Sprintf("%.6s", coin.Symbol)),
colorprice(fmt.Sprintf("%12s", humanize.Commaf(coin.PriceUSD))),

Loading…
Cancel
Save