37 lines
849 B
Go
37 lines
849 B
Go
package tui
|
|
|
|
import (
|
|
"github.com/gdamore/tcell/v2"
|
|
"github.com/rivo/tview"
|
|
)
|
|
|
|
// StatusBar represents a status bar of the user interface.
|
|
//
|
|
// status is a text view showing a status message.
|
|
type StatusBar struct {
|
|
*tview.Flex
|
|
status *tview.TextView
|
|
}
|
|
|
|
// NewStatusBar creates a new one-line status bar of the user interface.
|
|
func NewStatusBar() *StatusBar {
|
|
ui := StatusBar{
|
|
Flex: tview.NewFlex(),
|
|
}
|
|
|
|
statusLabel := tview.NewTextView().SetText("Status:")
|
|
statusLabel.SetTextColor(tcell.NewRGBColor(180, 180, 180))
|
|
ui.AddItem(statusLabel, 8, 0, false)
|
|
|
|
ui.status = tview.NewTextView()
|
|
ui.status.SetText("idle")
|
|
ui.status.SetTextColor(tcell.NewRGBColor(180, 180, 180))
|
|
ui.AddItem(ui.status, 0, 1, false)
|
|
|
|
return &ui
|
|
}
|
|
|
|
// SetStatus displays a status message.
|
|
func (ui *StatusBar) SetStatus(text string) {
|
|
ui.status.SetText(text)
|
|
}
|