narratio/editor/document.go

33 lines
500 B
Go

package editor
type Document struct {
Title string
Lines []string
in chan Command
refresh chan bool
}
func NewDocument(title string) *Document {
return &Document{
Title: title,
Lines: make([]string, 0),
in: make(chan Command),
refresh: make(chan bool),
}
}
func (d *Document) In() chan Command {
return d.in
}
func (d *Document) Out() chan bool {
return d.refresh
}
func (d *Document) Run() {
for cmd := range d.in {
cmd.Do(d.Lines)
d.refresh <- true
}
}