2024-05-10 12:06:40 +02:00
|
|
|
package editor
|
|
|
|
|
|
|
|
type GUI struct {
|
|
|
|
cmd chan Command
|
|
|
|
refresh chan bool
|
2024-09-14 14:54:41 +02:00
|
|
|
s *State
|
2024-05-10 12:06:40 +02:00
|
|
|
}
|
|
|
|
|
2024-09-14 14:54:41 +02:00
|
|
|
func NewGUI(s *State, refresh chan bool, cmd chan Command) *GUI {
|
2024-05-10 12:06:40 +02:00
|
|
|
g := &GUI{
|
|
|
|
refresh: refresh,
|
|
|
|
cmd: cmd,
|
2024-09-14 14:54:41 +02:00
|
|
|
s: s,
|
2024-05-10 12:06:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return g
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GUI) Run() {
|
|
|
|
go func() {
|
|
|
|
for range g.refresh {
|
|
|
|
g.Update()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GUI) Update() {
|
2024-09-14 14:54:41 +02:00
|
|
|
content := []string{g.s.Document.Title}
|
|
|
|
content = append(content, g.s.Document.Lines...)
|
2024-05-10 12:06:40 +02:00
|
|
|
|
|
|
|
}
|