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