44 lines
705 B
Go
44 lines
705 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
type TUIModel struct {
|
|
State *BrowserState
|
|
}
|
|
|
|
func NewTUIModel(state *BrowserState) TUIModel {
|
|
return TUIModel{State: state}
|
|
}
|
|
|
|
func (model TUIModel) Init() tea.Cmd {
|
|
return nil
|
|
}
|
|
|
|
func (model TUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
switch msg := msg.(type) {
|
|
case tea.KeyMsg:
|
|
switch msg.String() {
|
|
case "ctrl+c", "ctrl+d", "q":
|
|
return model, tea.Quit
|
|
}
|
|
}
|
|
|
|
return model, nil
|
|
}
|
|
|
|
func (model TUIModel) View() string {
|
|
return "pardon our dust"
|
|
}
|
|
|
|
func runTUI(state *BrowserState) {
|
|
p := tea.NewProgram(NewTUIModel(state))
|
|
if _, err := p.Run(); err != nil {
|
|
writeError(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
}
|