2
0
mirror of https://github.com/edouardparis/lntop synced 2024-11-16 00:12:44 +00:00
lntop/ui/views/header.go
Edouard f72c5ca099
V0.1.0 (#10)
* config: add Views

* refac views channels

* fix config default

* views: menu

* config default: add comment

* fix config default

* README: enhance config section

* fix README

* controller: F2 Menu

* views: transactions

* fix views: set current in layout

* fix menu

* ft transactions

* fix Help

* fix controller Menu

* view: transaction

* refac controller

* fix ui controller

* try some bold

* fix cursor

* refac color

* focus column transactions

* controller: add keyBinding Menu m

* help view: add menu

* fix cursor: push to the right

* refac remove current model

* ui: txs and channels sortable

* fix focus column

* view transaction: transaction dest addresses

* fix menu

* refac controller

* channels: sort

* rename current column

* refac cursor

* refac currentColumnIndex

* set cursor if view deleted

* remove previous

* clean view.View

* controller: ToggleView

* fix menu

* view txs: add config

* feat order

* fix channels sort
* feat transactions sort
* feat help: add asc/desc
* fix README
* color: magenta
* fix color
* fix views menu
* fix views help
* network backend: SubscribeTransactions
* pubsub: transactions
* controller.Listen: refresh transactions
* fix controller
* fix controller pubsub: no need for wallet ticker
* fix models transactions
* views channels: column SENT and RECEIVED
* update version
* fix README
* fix README
* fix models sort
* fix readme and default config
* fix readme
2019-05-14 18:13:59 +02:00

68 lines
1.3 KiB
Go

package views
import (
"fmt"
"regexp"
"github.com/edouardparis/lntop/ui/color"
"github.com/edouardparis/lntop/ui/models"
"github.com/jroimartin/gocui"
)
const (
HEADER = "myheader"
)
var versionReg = regexp.MustCompile(`(\d+\.)?(\d+\.)?(\*|\d+)`)
type Header struct {
Info *models.Info
}
func (h *Header) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
v, err := g.SetView(HEADER, x0, y0, x1, y0+2)
if err != nil {
if err != gocui.ErrUnknownView {
return err
}
}
v.Frame = false
version := h.Info.Version
matches := versionReg.FindStringSubmatch(h.Info.Version)
if len(matches) > 0 {
version = matches[0]
}
chain := ""
if len(h.Info.Chains) > 0 {
chain = h.Info.Chains[0]
}
network := "testnet"
if !h.Info.Testnet {
network = "mainnet"
}
sync := color.Yellow()("[syncing]")
if h.Info.Synced {
sync = color.Green()("[synced]")
}
v.Clear()
cyan := color.Cyan()
fmt.Fprintln(v, fmt.Sprintf("%s %s %s %s %s %s",
color.Cyan(color.Background)(h.Info.Alias),
cyan(fmt.Sprintf("%s-v%s", "lnd", version)),
fmt.Sprintf("%s %s", chain, network),
sync,
fmt.Sprintf("%s %d", cyan("height:"), h.Info.BlockHeight),
fmt.Sprintf("%s %d", cyan("peers:"), h.Info.NumPeers),
))
return nil
}
func NewHeader(info *models.Info) *Header {
return &Header{Info: info}
}