-
Notifications
You must be signed in to change notification settings - Fork 5
/
footer.go
50 lines (41 loc) · 1.27 KB
/
footer.go
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
package main
import (
"fmt"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
func footerWindow() *tview.Flex {
// The bottom row has some info on where we are.
layoutFooter = tview.NewFlex()
refreshFooter()
return layoutFooter
}
func refreshFooter() {
layoutFooter.Clear()
layoutShortcuts = tview.NewTextView().
SetToggleHighlights(true).
SetDynamicColors(true).
SetRegions(true).
SetWrap(false)
// shortcuts
if masterKey == nil {
keys := []tcell.Key{tcell.KeyCtrlG, tcell.KeyCtrlL, tcell.KeyEsc, tcell.KeyCtrlC}
for _, key := range keys {
fmt.Fprintf(layoutShortcuts, `[darkorange]%v ["%d"][white]%s[""] `, tview.Escape("<"+keyNames[key]+">"), key, shortCuts[key])
}
} else {
keys := []tcell.Key{tcell.KeyCtrlG, tcell.KeyCtrlL, tcell.KeyCtrlP, tcell.KeyEsc, tcell.KeyCtrlC}
for _, key := range keys {
fmt.Fprintf(layoutShortcuts, `[darkorange]%v ["%d"][white]%s[""] `, tview.Escape("<"+keyNames[key]+">"), key, shortCuts[key])
}
}
// right aligned version string
versionTextView := tview.NewTextView().
SetTextAlign(tview.AlignRight).
SetDynamicColors(true).
SetWrap(false)
versionTextView.SetText(S_FOOTER_COPYRIGHT)
// flex
layoutFooter.AddItem(layoutShortcuts, 0, 7, false)
layoutFooter.AddItem(versionTextView, 0, 3, false)
}