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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user