Initial, working but only with viewport height adjusted a little bit

This commit is contained in:
2026-03-28 16:12:33 +01:00
commit 7d94dee26b
16 changed files with 857 additions and 0 deletions

57
ui/model.go Normal file
View File

@@ -0,0 +1,57 @@
package ui
import (
"strings"
"git.pablu.de/pablu/pybug/internal/bridge"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
)
type Model struct {
currentFile string
cursor int
text string
width int
height int
lineCount int
bridge *bridge.Bridge
listenBridge chan string
messages []string
viewport viewport.Model
breakpoints map[string][]int
}
func NewModel(b *bridge.Bridge, file string, text string) Model {
c := b.Subscribe()
vp := viewport.New(0, 0)
return Model{
currentFile: file,
text: text,
cursor: 0,
lineCount: len(strings.Split(text, "\n")),
bridge: b,
breakpoints: make(map[string][]int),
listenBridge: c,
messages: make([]string, 0),
viewport: vp,
}
}
func ListenBridge(ch <-chan string) tea.Cmd {
return func() tea.Msg {
msg := <-ch
return StdoutMsg(msg)
}
}
type StdoutMsg string
func (m Model) Init() tea.Cmd {
return ListenBridge(m.listenBridge)
}