2
0
mirror of https://github.com/edouardparis/lntop synced 2024-11-16 00:12:44 +00:00
lntop/ui/views/help.go
Edouard Paris f869a471b5 add doc.go
2019-04-11 13:18:11 +02:00

63 lines
1.1 KiB
Go

package views
import (
"fmt"
"github.com/jroimartin/gocui"
"github.com/edouardparis/lntop/ui/color"
)
const (
HELP = "help"
)
type Help struct {
view *gocui.View
}
func (h Help) Name() string {
return HELP
}
func (h *Help) Wrap(v *gocui.View) view {
h.view = v
return h
}
func (h *Help) CursorDown() error {
return cursorDown(h.view, 1)
}
func (h *Help) CursorUp() error {
return cursorUp(h.view, 1)
}
func (h *Help) CursorRight() error {
return cursorRight(h.view, 1)
}
func (h *Help) CursorLeft() error {
return cursorLeft(h.view, 1)
}
func (h Help) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
var err error
h.view, err = g.SetView(HELP, x0-1, y0, x1, y1)
if err != nil {
if err != gocui.ErrUnknownView {
return err
}
}
h.view.Frame = false
fmt.Fprintln(h.view, "lntop 0.0.0 - (C) 2019 Edouard Paris")
fmt.Fprintln(h.view, "Released under the MIT License")
fmt.Fprintln(h.view, "")
fmt.Fprintln(h.view, fmt.Sprintf("%5s %s",
color.Cyan("F1 h:"), "show this help screen"))
_, err = g.SetCurrentView(HELP)
return err
}
func NewHelp() *Help { return &Help{} }