pelican/internal/ui/modeview.go
Dan Anglin 46f5f07105
All checks were successful
/ test (pull_request) Successful in 32s
/ lint (pull_request) Successful in 41s
feat(ui): show board's mode next to the status bar
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
2024-01-17 11:12:06 +00:00

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)
}