Dan Anglin
46f5f07105
Add a TextView primitive next to the status bar that displays the board's current mode. In this commit the baseFlex is replaced with a Grid primitive to prevent the need to add more Flex primitives. Part of apollo/pelican#23
35 lines
548 B
Go
35 lines
548 B
Go
package ui
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
"github.com/rivo/tview"
|
|
)
|
|
|
|
type modeView struct {
|
|
*tview.TextView
|
|
format string
|
|
}
|
|
|
|
func newModeView() *modeView {
|
|
format := "[white::b]%s[-:-:-:-]"
|
|
|
|
textView := tview.NewTextView()
|
|
|
|
textView.SetBackgroundColor(tcell.ColorGrey.TrueColor())
|
|
textView.SetTextAlign(tview.AlignLeft)
|
|
textView.SetDynamicColors(true)
|
|
|
|
obj := modeView{
|
|
TextView: textView,
|
|
format: format,
|
|
}
|
|
|
|
return &obj
|
|
}
|
|
|
|
func (m *modeView) update(mode boardMode) {
|
|
m.Clear()
|
|
fmt.Fprintf(m, m.format, mode)
|
|
}
|