chanding the architecure, removing the views ability to emit or listen to events

I liked my idea better but I recon I will hit less obstacles this way
This commit is contained in:
2026-02-24 23:22:19 +00:00
parent f40894577d
commit e64b1c31b9
12 changed files with 274 additions and 262 deletions
+16 -22
View File
@@ -1,38 +1,32 @@
package views
import (
"esdi/tui/internal/dom"
"esdi/tui/internal/events"
"esdi/tui/internal/ui"
"fmt"
"github.com/rivo/tview"
)
func bindOutputWindowEvents(
bus *events.Bus,
output *tview.TextView,
) {
bus.On(ui.PrintLogEv{}, func(e any) {
le, _ := e.(ui.PrintLogEv)
fmt.Fprintf(output, le.Log)
})
// func bindOutputWindowEvents(
// bus *events.Bus,
// output *tview.TextView,
// ) {
// bus.On(ui.PrintLogEv{}, func(e any) {
// le, _ := e.(ui.PrintLogEv)
// fmt.Fprintf(output, le.Log)
// })
// }
type OutputWinView struct {
TextArea *tview.TextView
}
func BuildOutputWindow(bus *events.Bus, doc *dom.DOM) error {
func NewOutputWinView() *OutputWinView {
var outputWin *tview.TextView
outputWin = tview.NewTextView().SetChangedFunc(func() {
bus.Emit(ui.RedrawEv{})
outputWin.ScrollToEnd()
})
outputWin.SetBorder(true).SetTitle("DebugWindow")
_, err := doc.NewUINode("output-window", nil, outputWin)
if err != nil {
return err
return &OutputWinView{
TextArea: outputWin,
}
bindOutputWindowEvents(bus, outputWin)
return nil
}