Full width highlight rows

pull/94/head
Miguel Mota 3 years ago
parent 3bc93134c9
commit 093084e859

@ -96,7 +96,7 @@ func (ct *Cointop) UpdateChart() error {
// ChartPoints calculates the the chart points
func (ct *Cointop) ChartPoints(symbol string, name string) error {
ct.debuglog("ChartPoints()")
maxX := ct.ClampedWidth()
maxX := ct.ChartWidth()
chartPointsLock.Lock()
defer chartPointsLock.Unlock()
@ -174,7 +174,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
// PortfolioChart renders the portfolio chart
func (ct *Cointop) PortfolioChart() error {
ct.debuglog("PortfolioChart()")
maxX := ct.ClampedWidth()
maxX := ct.ChartWidth()
chartPointsLock.Lock()
defer chartPointsLock.Unlock()
@ -373,3 +373,9 @@ func (ct *Cointop) ShowChartLoader() error {
return nil
}
// ChartWidth returns the width for chart
func (ct *Cointop) ChartWidth() int {
ct.debuglog("chartClampedWidth()")
return ct.width()
}

@ -17,13 +17,13 @@ func (ct *Cointop) GetCoinsTableHeaders() []string {
"symbol",
"price",
"marketcap",
"24hvolume",
"1hchange",
"24hchange",
"7dchange",
"totalsupply",
"availablesupply",
"lastupdated",
"24h_volume",
"1h_change",
"24h_change",
"7d_change",
"total_supply",
"available_supply",
"last_updated",
}
}

@ -150,7 +150,7 @@ func (ct *Cointop) SortedSupportedCurrencyConversions() []string {
// UpdateConvertMenu updates the convert menu
func (ct *Cointop) UpdateConvertMenu() error {
ct.debuglog("updateConvertMenu()")
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Currency Conversion %s\n\n", pad.Left("[q] close ", ct.maxTableWidth-24, " ")))
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Currency Conversion %s\n\n", pad.Left("[q] close ", ct.width()-24, " ")))
helpline := " Press the corresponding key to select currency for conversion\n\n"
cnt := 0
h := ct.Views.Menu.Height()

@ -16,7 +16,7 @@ func (ct *Cointop) UpdateHelp() {
}
sort.Strings(keys)
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Help %s\n\n", pad.Left("[q] close ", ct.maxTableWidth-10, " ")))
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" Help %s\n\n", pad.Left("[q] close ", ct.width()-9, " ")))
cnt := 0
h := ct.Views.Menu.Height()
percol := h - 11

@ -262,13 +262,13 @@ func (ct *Cointop) Keybindings(g *gocui.Gui) error {
case "first_page":
fn = ct.Keyfn(ct.FirstPage)
case "sort_column_1h_change":
fn = ct.Sortfn("1hchange", true)
fn = ct.Sortfn("1h_change", true)
case "sort_column_24h_change":
fn = ct.Sortfn("24hchange", true)
fn = ct.Sortfn("24h_change", true)
case "sort_column_7d_change":
fn = ct.Sortfn("7dchange", true)
fn = ct.Sortfn("7d_change", true)
case "sort_column_available_supply":
fn = ct.Sortfn("availablesupply", true)
fn = ct.Sortfn("available_supply", true)
case "toggle_row_chart":
fn = ct.Keyfn(ct.ToggleCoinChart)
case "move_to_page_visible_first_row":
@ -290,17 +290,17 @@ func (ct *Cointop) Keybindings(g *gocui.Gui) error {
case "sort_column_rank":
fn = ct.Sortfn("rank", false)
case "sort_column_total_supply":
fn = ct.Sortfn("totalsupply", true)
fn = ct.Sortfn("total_supply", true)
case "sort_column_last_updated":
fn = ct.Sortfn("lastupdated", true)
fn = ct.Sortfn("last_updated", true)
case "sort_column_24h_volume":
fn = ct.Sortfn("24hvolume", true)
fn = ct.Sortfn("24h_volume", true)
case "sort_column_balance":
fn = ct.Sortfn("balance", true)
case "sort_column_holdings":
fn = ct.Sortfn("holdings", true)
case "sort_column_percent_holdings":
fn = ct.Sortfn("percentholdings", true)
fn = ct.Sortfn("percent_holdings", true)
case "last_page":
fn = ct.Keyfn(ct.LastPage)
case "open_search":

@ -13,10 +13,9 @@ var lastWidth int
func (ct *Cointop) layout() error {
ct.debuglog("layout()")
maxY := ct.height()
maxX := ct.ClampedWidth()
maxX := ct.width()
topOffset := 0
headerHeight := 1
marketbarHeight := 1
chartHeight := ct.State.chartHeight
@ -92,7 +91,7 @@ func (ct *Cointop) layout() error {
tableOffsetX := ct.State.tableOffsetX
topOffset = topOffset + chartHeight
if err := ct.ui.SetView(ct.Views.TableHeader, tableOffsetX, topOffset, ct.maxTableWidth, topOffset+2); err != nil {
if err := ct.ui.SetView(ct.Views.TableHeader, tableOffsetX, topOffset, maxX, topOffset+2); err != nil {
ct.Views.TableHeader.SetFrame(false)
ct.Views.TableHeader.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.TableHeader.Name()))
ct.Views.TableHeader.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.TableHeader.Name()))
@ -100,7 +99,7 @@ func (ct *Cointop) layout() error {
}
topOffset = topOffset + headerHeight
if err := ct.ui.SetView(ct.Views.Table, tableOffsetX, topOffset, ct.maxTableWidth, maxY-statusbarHeight); err != nil {
if err := ct.ui.SetView(ct.Views.Table, tableOffsetX, topOffset, maxX, maxY-statusbarHeight); err != nil {
ct.Views.Table.SetFrame(false)
ct.Views.Table.SetHighlight(true)
ct.Views.Table.SetSelFgColor(ct.colorscheme.gocuiFgColor("table_row_active"))
@ -116,7 +115,7 @@ func (ct *Cointop) layout() error {
}
if !ct.State.hideStatusbar {
if err := ct.ui.SetView(ct.Views.Statusbar, 0, maxY-statusbarHeight-1, ct.maxTableWidth, maxY); err != nil {
if err := ct.ui.SetView(ct.Views.Statusbar, 0, maxY-statusbarHeight-1, maxX, maxY); err != nil {
ct.Views.Statusbar.SetFrame(false)
ct.Views.Statusbar.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.Statusbar.Name()))
ct.Views.Statusbar.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.Statusbar.Name()))
@ -131,7 +130,7 @@ func (ct *Cointop) layout() error {
}
}
if err := ct.ui.SetView(ct.Views.SearchField, 0, maxY-2, ct.maxTableWidth, maxY); err != nil {
if err := ct.ui.SetView(ct.Views.SearchField, 0, maxY-2, maxX, maxY); err != nil {
ct.Views.SearchField.SetEditable(true)
ct.Views.SearchField.SetWrap(true)
ct.Views.SearchField.SetFrame(false)
@ -139,7 +138,7 @@ func (ct *Cointop) layout() error {
ct.Views.SearchField.SetBgColor(ct.colorscheme.gocuiBgColor("searchbar"))
}
if err := ct.ui.SetView(ct.Views.Menu, 1, 1, ct.maxTableWidth-1, maxY-1); err != nil {
if err := ct.ui.SetView(ct.Views.Menu, 1, 1, maxX-1, maxY-1); err != nil {
ct.Views.Menu.SetFrame(false)
ct.Views.Menu.SetFgColor(ct.colorscheme.gocuiFgColor("menu"))
ct.Views.Menu.SetBgColor(ct.colorscheme.gocuiBgColor("menu"))

@ -27,9 +27,9 @@ func (ct *Cointop) GetPortfolioTableHeaders() []string {
"price",
"holdings",
"balance",
"24hchange",
"percentholdings",
"lastupdated",
"24h_change",
"percent_holdings",
"last_updated",
}
}
@ -199,7 +199,7 @@ func (ct *Cointop) UpdatePortfolioUpdateMenu() error {
mode = "Add"
submitText = "Add"
}
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Portfolio Entry %s\n\n", mode, pad.Left("[q] close ", ct.maxTableWidth-26, " ")))
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Portfolio Entry %s\n\n", mode, pad.Left("[q] close ", ct.width()-25, " ")))
label := fmt.Sprintf(" Enter holdings for %s %s", ct.colorscheme.MenuLabel(coin.Name), current)
content := fmt.Sprintf("%s\n%s\n\n%s%s\n\n\n [Enter] %s [ESC] Cancel", header, label, strings.Repeat(" ", 29), coin.Symbol, submitText)

@ -224,10 +224,12 @@ func (ct *Cointop) UpdatePriceAlertsUpdateMenu(isNew bool) error {
var mode string
var current string
var submitText string
var offset int
if exists {
mode = "Edit"
current = fmt.Sprintf("(current %s%s)", ct.CurrencySymbol(), currentPrice)
submitText = "Set"
offset = ct.width() - 21
} else {
coin := ct.HighlightedRowCoin()
coinName = coin.Name
@ -235,8 +237,9 @@ func (ct *Cointop) UpdatePriceAlertsUpdateMenu(isNew bool) error {
value = fmt.Sprintf("> %s", currentPrice)
mode = "Create"
submitText = "Create"
offset = ct.width() - 23
}
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Alert Entry %s\n\n", mode, pad.Left("[q] close ", ct.maxTableWidth-26, " ")))
header := ct.colorscheme.MenuHeader(fmt.Sprintf(" %s Alert Entry %s\n\n", mode, pad.Left("[q] close ", offset, " ")))
label := fmt.Sprintf(" Enter target price for %s %s", ct.colorscheme.MenuLabel(coinName), current)
content := fmt.Sprintf("%s\n%s\n\n%s%s\n\n\n [Enter] %s [ESC] Cancel", header, label, strings.Repeat(" ", 29), ct.State.currencyConversion, submitText)

@ -49,19 +49,19 @@ func (ct *Cointop) Sort(sortBy string, desc bool, list []*Coin, renderHeaders bo
return a.Balance < b.Balance
case "marketcap":
return a.MarketCap < b.MarketCap
case "24hvolume":
case "24h_volume":
return a.Volume24H < b.Volume24H
case "1hchange":
case "1h_change":
return a.PercentChange1H < b.PercentChange1H
case "24hchange":
case "24h_change":
return a.PercentChange24H < b.PercentChange24H
case "7dchange":
case "7d_change":
return a.PercentChange7D < b.PercentChange7D
case "totalsupply":
case "total_supply":
return a.TotalSupply < b.TotalSupply
case "availablesupply":
case "available_supply":
return a.AvailableSupply < b.AvailableSupply
case "lastupdated":
case "last_updated":
return a.LastUpdated < b.LastUpdated
default:
return a.Rank < b.Rank

@ -47,7 +47,7 @@ func (ct *Cointop) UpdateStatusbar(s string) error {
content = fmt.Sprintf("%s [E]Edit [+]Add", helpStr)
} else {
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.maxTableWidth, " ")
str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.width(), " ")
v := fmt.Sprintf("%s", ct.Version())
end := len(str) - len(v) + 2
if end > len(str) {

@ -28,13 +28,13 @@ func TableColumnOrder() []string {
"holdings",
"balance",
"marketcap",
"24hvolume",
"1hchange",
"7dchange",
"totalsupply",
"availablesupply",
"percentholdings",
"lastupdated",
"24h_volume",
"1h_change",
"7d_change",
"total_supply",
"available_supply",
"percent_holdings",
"last_updated",
}
}

@ -30,23 +30,23 @@ func (ct *Cointop) UpdateTableHeader() error {
baseColor := ct.colorscheme.TableHeaderSprintf()
possibleHeaders := map[string]*t{
"rank": {baseColor, "[r]ank", 0, 1, " "},
"name": {baseColor, "[n]ame", 0, 11, " "},
"symbol": {baseColor, "[s]ymbol", 4, 0, " "},
"targetprice": {baseColor, "[t]arget price", 2, 0, " "},
"price": {baseColor, "[p]rice", 2, 0, " "},
"frequency": {baseColor, "frequency", 1, 0, " "},
"holdings": {baseColor, "[h]oldings", 5, 0, " "},
"balance": {baseColor, "[b]alance", 5, 0, " "},
"marketcap": {baseColor, "[m]arket cap", 5, 0, " "},
"24hvolume": {baseColor, "24H [v]olume", 3, 0, " "},
"1hchange": {baseColor, "[1]H%", 5, 0, " "},
"24hchange": {baseColor, "[2]4H%", 3, 0, " "},
"7dchange": {baseColor, "[7]D%", 4, 0, " "},
"totalsupply": {baseColor, "[t]otal supply", 7, 0, " "},
"availablesupply": {baseColor, "[a]vailable supply", 0, 0, " "},
"percentholdings": {baseColor, "[%]holdings", 2, 0, " "},
"lastupdated": {baseColor, "last [u]pdated", 3, 0, " "},
"rank": {baseColor, "[r]ank", 0, 1, " "},
"name": {baseColor, "[n]ame", 0, 11, " "},
"symbol": {baseColor, "[s]ymbol", 4, 0, " "},
"target_price": {baseColor, "[t]arget price", 2, 0, " "},
"price": {baseColor, "[p]rice", 2, 0, " "},
"frequency": {baseColor, "frequency", 1, 0, " "},
"holdings": {baseColor, "[h]oldings", 5, 0, " "},
"balance": {baseColor, "[b]alance", 5, 0, " "},
"marketcap": {baseColor, "[m]arket cap", 5, 0, " "},
"24h_volume": {baseColor, "24H [v]olume", 3, 0, " "},
"1h_change": {baseColor, "[1]H%", 5, 0, " "},
"24h_change": {baseColor, "[2]4H%", 3, 0, " "},
"7d_change": {baseColor, "[7]D%", 4, 0, " "},
"total_supply": {baseColor, "[t]otal supply", 7, 0, " "},
"available_supply": {baseColor, "[a]vailable supply", 0, 0, " "},
"percent_holdings": {baseColor, "[%]holdings", 2, 0, " "},
"last_updated": {baseColor, "last [u]pdated", 3, 0, " "},
}
for k := range possibleHeaders {

@ -241,7 +241,8 @@ func (t *Table) Fprint(w io.Writer) {
fmt.Fprintf(w, "%s", s)
}
fmt.Fprintf(w, "\n")
// fill in rest of row with empty spaces to highlight all of row
fmt.Fprintf(w, strings.Repeat(" ", t.width)+"\n")
}
}

Loading…
Cancel
Save