Add basic terminal user interface
This commit is contained in:
parent
bf4e19378d
commit
5956331a28
9 changed files with 878 additions and 0 deletions
37
tui/statusbar.go
Normal file
37
tui/statusbar.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue