diff --git a/spectator.go b/spectator.go index e2f85c7..8c1e321 100644 --- a/spectator.go +++ b/spectator.go @@ -37,6 +37,10 @@ type Spectator struct { // when closed will cause the Spectator to exit the render loop. Die chan struct{} + + // User, if populated, will return a stream of (ostensibly keyboard) events + // for use outside of the Spectator. + User chan termbox.Event } // SetIDs is implemented so Spectator can be used as a client.Player. @@ -58,6 +62,8 @@ func (s *Spectator) Spectate() error { return err } + termbox.SetInputMode(termbox.InputMouse) + s.viewX, s.viewY = termbox.Size() events := make(chan termbox.Event, 1024) @@ -101,6 +107,10 @@ func (s *Spectator) Spectate() error { err = fmt.Errorf("Quitting because of termbox error:\n%v\n", event.Err) return } + + if s.User != nil { + s.User <- event + } case update := <-s.StateStream: termbox.Clear(termbox.ColorBlack, termbox.ColorBlack)