}
}
-// make chan for termbox events and run a poller to send events to the channel
-// - return the channel
-func new_tb_chan() chan termbox.Event {
- termboxChan := make(chan termbox.Event)
- go func() {
- for {
- termboxChan <- termbox.PollEvent()
- }
- }()
- return termboxChan
-}
-
// get into a run loop
func (app *App) Run() {
app.done = make(chan struct{})
app.wi.SetWaitInterval(time.Second)
- termboxChan := new_tb_chan()
+ termboxChan := app.screen.TermBoxChan()
for !app.Finished() {
select {
func (s *TermboxScreen) Size() (int, int) {
return s.width, s.height
}
+
+// create a channel for termbox.Events and run a poller to send
+// these events to the channel. Return the channel.
+func (s TermboxScreen) TermBoxChan() chan termbox.Event {
+ termboxChan := make(chan termbox.Event)
+ go func() {
+ for {
+ termboxChan <- termbox.PollEvent()
+ }
+ }()
+ return termboxChan
+}