add stubs for bbtui

This commit is contained in:
2023-01-27 00:08:56 -08:00
parent 9b511cb5ea
commit 4cc204657c
2 changed files with 87 additions and 0 deletions

57
graph/graph.go Normal file
View File

@@ -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
}

30
graph/help/help.go Normal file
View File

@@ -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
}