blob: a6329bcc90779f22cf1cce0cbd14d2740ff9b9d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
package ui
import (
"fmt"
"github.com/jroimartin/gocui"
)
type StatusView struct {
Name string
gui *gocui.Gui
view *gocui.View
}
func NewStatusView(name string, gui *gocui.Gui) (statusview *StatusView) {
statusview = new(StatusView)
// populate main fields
statusview.Name = name
statusview.gui = gui
return statusview
}
func (view *StatusView) Setup(v *gocui.View, header *gocui.View) error {
// set view options
view.view = v
view.view.Frame = false
view.view.BgColor = gocui.ColorDefault + gocui.AttrReverse
// set keybindings
// if err := view.gui.SetKeybinding(view.Name, gocui.KeyArrowDown, gocui.ModNone, func(*gocui.Gui, *gocui.View) error { return view.CursorDown() }); err != nil {
// return err
// }
// if err := view.gui.SetKeybinding(view.Name, gocui.KeyArrowUp, gocui.ModNone, func(*gocui.Gui, *gocui.View) error { return view.CursorUp() }); err != nil {
// return err
// }
view.Render()
return nil
}
func (view *StatusView) CursorDown() error {
return nil
}
func (view *StatusView) CursorUp() error {
return nil
}
func (view *StatusView) KeyHelp() string {
return Formatting.Control("[^C]") + ": Quit " +
Formatting.Control("[^Space]") + ": Switch View "
}
func (view *StatusView) Render() error {
view.gui.Update(func(g *gocui.Gui) error {
view.view.Clear()
fmt.Fprintln(view.view, view.KeyHelp() + " | " + Views.lookup[view.gui.CurrentView().Name()].KeyHelp())
return nil
})
// todo: blerg
return nil
}
|