mirror of
https://github.com/miguelmota/cointop
synced 2024-11-10 13:10:26 +00:00
Update statusbar spacing
This commit is contained in:
parent
a9473e354c
commit
00d654aa74
@ -10,6 +10,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/miguelmota/cointop/pkg/asciitable"
|
"github.com/miguelmota/cointop/pkg/asciitable"
|
||||||
"github.com/miguelmota/cointop/pkg/humanize"
|
"github.com/miguelmota/cointop/pkg/humanize"
|
||||||
@ -126,7 +127,7 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
|
|||||||
case "price":
|
case "price":
|
||||||
text := humanize.Commaf(coin.Price)
|
text := humanize.Commaf(coin.Price)
|
||||||
symbolPadding := 1
|
symbolPadding := 1
|
||||||
ct.SetTableColumnWidth(header, len(text)+symbolPadding)
|
ct.SetTableColumnWidth(header, utf8.RuneCountInString(text)+symbolPadding)
|
||||||
ct.SetTableColumnAlignLeft(header, false)
|
ct.SetTableColumnAlignLeft(header, false)
|
||||||
rowCells = append(rowCells,
|
rowCells = append(rowCells,
|
||||||
&table.RowCell{
|
&table.RowCell{
|
||||||
@ -353,7 +354,7 @@ func (ct *Cointop) UpdatePortfolioUpdateMenu() error {
|
|||||||
ct.Views.Menu.SetFrame(true)
|
ct.Views.Menu.SetFrame(true)
|
||||||
ct.Views.Menu.Update(content)
|
ct.Views.Menu.Update(content)
|
||||||
ct.Views.Input.Write(value)
|
ct.Views.Input.Write(value)
|
||||||
ct.Views.Input.SetCursor(len(value), 0)
|
ct.Views.Input.SetCursor(utf8.RuneCountInString(value), 0)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
@ -14,14 +14,14 @@ func (ct *Cointop) Sort(sortBy string, desc bool, list []*Coin, renderHeaders bo
|
|||||||
ct.debuglog("sort()")
|
ct.debuglog("sort()")
|
||||||
sortlock.Lock()
|
sortlock.Lock()
|
||||||
defer sortlock.Unlock()
|
defer sortlock.Unlock()
|
||||||
|
ct.State.sortBy = sortBy
|
||||||
|
ct.State.sortDesc = desc
|
||||||
if list == nil {
|
if list == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(list) < 2 {
|
if len(list) < 2 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ct.State.sortBy = sortBy
|
|
||||||
ct.State.sortDesc = desc
|
|
||||||
sort.Slice(list[:], func(i, j int) bool {
|
sort.Slice(list[:], func(i, j int) bool {
|
||||||
if ct.State.sortDesc {
|
if ct.State.sortDesc {
|
||||||
i, j = j, i
|
i, j = j, i
|
||||||
|
@ -2,6 +2,7 @@ package cointop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/miguelmota/cointop/pkg/open"
|
"github.com/miguelmota/cointop/pkg/open"
|
||||||
"github.com/miguelmota/cointop/pkg/pad"
|
"github.com/miguelmota/cointop/pkg/pad"
|
||||||
@ -53,9 +54,10 @@ func (ct *Cointop) UpdateStatusbar(s string) error {
|
|||||||
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 := ct.Version()
|
v := ct.Version()
|
||||||
end := len(str) - len(v) + 2
|
size := utf8.RuneCountInString(str)
|
||||||
if end > len(str) {
|
end := size - utf8.RuneCountInString(v) + 2
|
||||||
end = len(str)
|
if end > size {
|
||||||
|
end = size
|
||||||
}
|
}
|
||||||
|
|
||||||
content = str[:end] + v
|
content = str[:end] + v
|
||||||
|
Loading…
Reference in New Issue
Block a user