diff options
| author | tjp <tjp@ctrl-c.club> | 2024-01-17 08:55:42 -0700 |
|---|---|---|
| committer | tjp <tjp@ctrl-c.club> | 2024-01-17 08:55:42 -0700 |
| commit | dd2a06c1e1391fe6242015330b7c61fa37fd67cc (patch) | |
| tree | 8b07e964f40f70de898046e5435c8932768f2b21 /tui.go | |
| parent | dfebc9013b5414e9a3c5f940704e831c31ce35d2 (diff) | |
start of a bubbletea TUI
Diffstat (limited to 'tui.go')
| -rw-r--r-- | tui.go | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ +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) + } +} |
