summaryrefslogtreecommitdiff
path: root/tui.go
diff options
context:
space:
mode:
Diffstat (limited to 'tui.go')
-rw-r--r--tui.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/tui.go b/tui.go
new file mode 100644
index 0000000..12bb665
--- /dev/null
+++ b/tui.go
@@ -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)
+ }
+}