Stepping and showing execution point now work

This commit is contained in:
2026-03-28 17:18:26 +01:00
parent 41d0dd3b14
commit 587c8f9396
7 changed files with 184 additions and 88 deletions

View File

@@ -16,8 +16,11 @@ type Model struct {
width int
height int
bridge *bridge.Bridge
listenBridge chan string
bridge *bridge.Bridge
listenBridge chan string
listenBridgeExecutionsStopped chan bridge.ExecutionPoint
currExecutionPoint bridge.ExecutionPoint
messages []string
stdoutOutput viewport.Model
@@ -29,6 +32,7 @@ type Model struct {
func NewModel(b *bridge.Bridge, file string, text string) Model {
c := b.Subscribe()
c2 := b.SubscribeStopped()
stdoutOutput := viewport.New(0, 0)
codeViewer := viewport.New(0, 0)
@@ -38,9 +42,14 @@ func NewModel(b *bridge.Bridge, file string, text string) Model {
text: text,
textLines: len(strings.Split(text, "\n")),
bridge: b,
listenBridge: c,
bridge: b,
listenBridge: c,
listenBridgeExecutionsStopped: c2,
currExecutionPoint: bridge.ExecutionPoint{
File: file,
Line: 0,
},
breakpoints: make(map[string][]int),
messages: make([]string, 0),
@@ -57,8 +66,19 @@ func ListenBridge(ch <-chan string) tea.Cmd {
}
}
func ListenBridgeExecutionsStopped(ch <-chan bridge.ExecutionPoint) tea.Cmd {
return func() tea.Msg {
msg := <-ch
return ExecutionStoppedMsg(msg)
}
}
type ExecutionStoppedMsg bridge.ExecutionPoint
type StdoutMsg string
func (m Model) Init() tea.Cmd {
return ListenBridge(m.listenBridge)
return tea.Batch(
ListenBridge(m.listenBridge),
ListenBridgeExecutionsStopped(m.listenBridgeExecutionsStopped),
)
}