diff --git a/cointop/chart.go b/cointop/chart.go index 5de5204..25143bb 100644 --- a/cointop/chart.go +++ b/cointop/chart.go @@ -11,9 +11,11 @@ import ( func (ct *Cointop) updateChart() error { maxX := ct.Width() + if maxX > ct.maxtablewidth { + maxX = ct.maxtablewidth + } coin := ct.selectedCoinName() ct.chartPoints(maxX, coin) - for i := range ct.chartpoints { var s string for j := range ct.chartpoints[i] { diff --git a/cointop/cointop.go b/cointop/cointop.go index a03037e..2bf6f92 100644 --- a/cointop/cointop.go +++ b/cointop/cointop.go @@ -43,6 +43,7 @@ type Cointop struct { refreshticker *time.Ticker forcerefresh chan bool selectedcoin *apt.Coin + maxtablewidth int } // Run runs cointop @@ -64,6 +65,7 @@ func Run() { page: 0, perpage: 100, forcerefresh: make(chan bool), + maxtablewidth: 175, } g.SetManagerFunc(ct.layout) if err := ct.keybindings(g); err != nil { diff --git a/cointop/layout.go b/cointop/layout.go index aaf56ea..b0993fa 100644 --- a/cointop/layout.go +++ b/cointop/layout.go @@ -34,7 +34,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error { } topOffset = topOffset + chartHeight - if v, err := g.SetView("header", 0, topOffset, maxX, topOffset+2); err != nil { + if v, err := g.SetView("header", 0, topOffset, ct.maxtablewidth, topOffset+2); err != nil { if err != gocui.ErrUnknownView { return err } @@ -46,7 +46,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error { } topOffset = topOffset + 1 - if v, err := g.SetView("table", 0, topOffset, maxX, maxY-1); err != nil { + if v, err := g.SetView("table", 0, topOffset, ct.maxtablewidth, maxY-1); err != nil { if err != gocui.ErrUnknownView { return err } @@ -60,7 +60,7 @@ func (ct *Cointop) layout(g *gocui.Gui) error { ct.rowChanged() } - if v, err := g.SetView("statusbar", 0, maxY-2, maxX, maxY); err != nil { + if v, err := g.SetView("statusbar", 0, maxY-2, ct.maxtablewidth, maxY); err != nil { if err != gocui.ErrUnknownView { return err } diff --git a/cointop/statusbar.go b/cointop/statusbar.go index 808dfe8..c456ceb 100644 --- a/cointop/statusbar.go +++ b/cointop/statusbar.go @@ -7,13 +7,12 @@ import ( ) func (ct *Cointop) updateStatusbar(s string) { - maxX := ct.Width() ct.Update(func() { ct.statusbarview.Clear() currpage := ct.getCurrentPage() totalpages := ct.getTotalPages() base := "[q]uit [?]help [c]hart" - fmt.Fprintln(ct.statusbarview, pad.Right(fmt.Sprintf("%v [← →]page %v/%v %s", base, currpage, totalpages, s), maxX, " ")) + fmt.Fprintln(ct.statusbarview, pad.Right(fmt.Sprintf("%v [← →]page %v/%v %s", base, currpage, totalpages, s), ct.maxtablewidth, " ")) }) } diff --git a/pkg/table/table.go b/pkg/table/table.go index c98d398..51c4db5 100644 --- a/pkg/table/table.go +++ b/pkg/table/table.go @@ -139,8 +139,7 @@ func (t *Table) Format() *Table { } } - t.normalizeColWidthPerc() - + //t.normalizeColWidthPerc() unused := t.width - t.colWidth() if unused <= 0 { return t