its all events LETS GO - I still need to make it be all events
This commit is contained in:
@@ -2,23 +2,37 @@ package views
|
||||
|
||||
import (
|
||||
"esdi/tui/internal/dom"
|
||||
"esdi/tui/internal/events"
|
||||
"esdi/tui/internal/ui"
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func BuildOutputWindow(root *dom.DOM, ctx *ui.UIContext) error {
|
||||
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 BuildOutputWindow(bus *events.Bus, doc *dom.DOM) error {
|
||||
var outputWin *tview.TextView
|
||||
outputWin = tview.NewTextView().SetChangedFunc(func() {
|
||||
ctx.Redraw()
|
||||
bus.Emit(ui.RedrawEv{})
|
||||
outputWin.ScrollToEnd()
|
||||
})
|
||||
|
||||
outputWin.SetBorder(true).SetTitle("DebugWindow")
|
||||
_, err := root.NewUINode("output-window", nil, outputWin)
|
||||
_, err := doc.NewUINode("output-window", nil, outputWin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bindOutputWindowEvents(bus, outputWin)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user