From 4cc204657c003871073278cf90987847e50cb25b Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Fri, 27 Jan 2023 00:08:56 -0800 Subject: [PATCH] add stubs for bbtui --- graph/graph.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++ graph/help/help.go | 30 ++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 graph/graph.go create mode 100644 graph/help/help.go diff --git a/graph/graph.go b/graph/graph.go new file mode 100644 index 0000000..4d25f00 --- /dev/null +++ b/graph/graph.go @@ -0,0 +1,57 @@ +package graph + +import ( + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" + "github.com/taigrr/gico/graph/help" +) + +type Graph struct { + Help help.Help + df lipgloss.DoeFoot +} + +func (g Graph) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + var cmd tea.Cmd + switch msg := msg.(type) { + case tea.WindowSizeMsg: + h, _ := g.Help.Update(msg) + t, _ := h.(help.Help) + g.Help = t + case tea.KeyMsg: + switch msg.String() { + case "ctrl+c", "q": + return g, tea.Quit + case "right", "l": + case "up", "k": + case "down", "j": + case "left", "h": + case "G": + default: + h, _ := g.Help.Update(msg) + t, _ := h.(help.Help) + g.Help = t + } + } + return g, cmd +} + +func (g Graph) Init() tea.Cmd { + return nil +} + +func (g Graph) View() string { + return "" +} + +func New() Graph { + var g Graph + g.Help = help.New() + return g +} + +func (g Graph) UpdateDoeFoot(df lipgloss.DoeFoot) Graph { + g.df = df + g.Help = g.Help.UpdateDoeFoot(df) + return g +} diff --git a/graph/help/help.go b/graph/help/help.go new file mode 100644 index 0000000..1c56322 --- /dev/null +++ b/graph/help/help.go @@ -0,0 +1,30 @@ +package help + +import ( + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" +) + +type Help struct { + df lipgloss.DoeFoot +} + +func (h Help) Update(m tea.Msg) (tea.Model, tea.Cmd) { + return h, nil +} +func (h Help) Init() tea.Cmd { + return nil +} + +func (h Help) View() string { + return "" +} + +func New() Help { + return Help{} +} + +func (h Help) UpdateDoeFoot(df lipgloss.DoeFoot) Help { + h.df = df + return h +}