Format fixes

pull/94/head
Miguel Mota 3 years ago
parent 3c9b482708
commit 68ff8ecfb7

@ -22,7 +22,7 @@ import (
// TODO: clean up and optimize codebase // TODO: clean up and optimize codebase
// ErrInvalidAPIChoice is error for invalid API choice // ErrInvalidAPIChoice is error for invalid API choice
var ErrInvalidAPIChoice = errors.New("Invalid API choice") var ErrInvalidAPIChoice = errors.New("invalid API choice")
// Views are all views in cointop // Views are all views in cointop
type Views struct { type Views struct {
@ -229,7 +229,7 @@ func NewCointop(config *Config) (*Cointop, error) {
page: 0, page: 0,
perPage: int(perPage), perPage: int(perPage),
portfolio: &Portfolio{ portfolio: &Portfolio{
Entries: make(map[string]*PortfolioEntry, 0), Entries: make(map[string]*PortfolioEntry),
}, },
portfolioTableColumns: DefaultPortfolioTableHeaders, portfolioTableColumns: DefaultPortfolioTableHeaders,
chartHeight: 10, chartHeight: 10,

@ -24,8 +24,8 @@ func (ct *Cointop) height() int {
return h return h
} }
// viewWidth returns view width // ViewWidth returns view width
func (ct *Cointop) viewWidth(view string) int { func (ct *Cointop) ViewWidth(view string) int {
ct.debuglog("viewWidth()") ct.debuglog("viewWidth()")
v, err := ct.g.View(view) v, err := ct.g.View(view)
if err != nil { if err != nil {

@ -92,14 +92,13 @@ func (ct *Cointop) SortDesc() error {
// SortPrevCol sorts the previous column // SortPrevCol sorts the previous column
func (ct *Cointop) SortPrevCol() error { func (ct *Cointop) SortPrevCol() error {
ct.debuglog("sortPrevCol()") ct.debuglog("sortPrevCol()")
nextsortBy := ct.TableColumnOrder[0]
i := ct.GetSortColIndex() i := ct.GetSortColIndex()
k := i - 1 k := i - 1
if k < 0 { if k < 0 {
k = 0 k = 0
} }
nextsortBy = ct.TableColumnOrder[k] nextsortBy := ct.TableColumnOrder[k]
ct.Sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true) ct.Sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true)
ct.UpdateTable() ct.UpdateTable()
return nil return nil
@ -108,7 +107,6 @@ func (ct *Cointop) SortPrevCol() error {
// SortNextCol sorts the next column // SortNextCol sorts the next column
func (ct *Cointop) SortNextCol() error { func (ct *Cointop) SortNextCol() error {
ct.debuglog("sortNextCol()") ct.debuglog("sortNextCol()")
nextsortBy := ct.TableColumnOrder[0]
l := len(ct.TableColumnOrder) l := len(ct.TableColumnOrder)
i := ct.GetSortColIndex() i := ct.GetSortColIndex()
k := i + 1 k := i + 1
@ -116,7 +114,7 @@ func (ct *Cointop) SortNextCol() error {
k = l - 1 k = l - 1
} }
nextsortBy = ct.TableColumnOrder[k] nextsortBy := ct.TableColumnOrder[k]
ct.Sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true) ct.Sort(nextsortBy, ct.State.sortDesc, ct.State.coins, true)
ct.UpdateTable() ct.UpdateTable()
return nil return nil

@ -48,7 +48,7 @@ func (ct *Cointop) UpdateStatusbar(s string) error {
} else { } else {
base := fmt.Sprintf("%s %sChart %sRange %sSearch %sConvert %s %s", helpStr, "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText) base := fmt.Sprintf("%s %sChart %sRange %sSearch %sConvert %s %s", helpStr, "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText)
str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.width(), " ") str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.width(), " ")
v := fmt.Sprintf("%s", ct.Version()) v := ct.Version()
end := len(str) - len(v) + 2 end := len(str) - len(v) + 2
if end > len(str) { if end > len(str) {
end = len(str) end = len(str)

@ -2,7 +2,6 @@ package cointop
import ( import (
"fmt" "fmt"
"math"
"net/url" "net/url"
"strings" "strings"
@ -118,7 +117,7 @@ func (ct *Cointop) GetTableCoinsSlice() []*Coin {
start = 0 start = 0
} }
if end >= size-1 { if end >= size-1 {
start = int(math.Floor(float64(start/100)) * 100) start = int(float64(start/100) * 100)
end = size - 1 end = size - 1
} }
if start < 0 { if start < 0 {

@ -1,14 +1,12 @@
package cointop package cointop
import ( import (
"fmt"
"github.com/miguelmota/gocui" "github.com/miguelmota/gocui"
) )
// UpdateUI takes a callback which updates the view // UpdateUI takes a callback which updates the view
func (ct *Cointop) UpdateUI(f func() error) { func (ct *Cointop) UpdateUI(f func() error) {
ct.debuglog(fmt.Sprintf("UpdateUI()")) ct.debuglog("UpdateUI()")
if ct.g == nil { if ct.g == nil {
return return

@ -14,10 +14,10 @@ import (
) )
// ErrPingFailed is the error for when pinging the API fails // ErrPingFailed is the error for when pinging the API fails
var ErrPingFailed = errors.New("Failed to ping") var ErrPingFailed = errors.New("failed to ping")
// ErrNotFound is the error when the target is not found // ErrNotFound is the error when the target is not found
var ErrNotFound = errors.New("Not found") var ErrNotFound = errors.New("not found")
// Service service // Service service
type Service struct { type Service struct {

@ -14,10 +14,10 @@ import (
) )
// ErrQuoteNotFound is the error for when a quote is not found // ErrQuoteNotFound is the error for when a quote is not found
var ErrQuoteNotFound = errors.New("Quote not found") var ErrQuoteNotFound = errors.New("quote not found")
// ErrPingFailed is the error for when pinging the API fails // ErrPingFailed is the error for when pinging the API fails
var ErrPingFailed = errors.New("Failed to ping") var ErrPingFailed = errors.New("failed to ping")
// Service service // Service service
type Service struct { type Service struct {

Loading…
Cancel
Save