Skip to content
Myr

Catch errors when reading keyboard input

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 50b16d2 · Browse files · 1 file+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−1 removed

  • other:+8 added−1 removed

1 file+8 added−1 removed

modified:tea.go+8 added-1 removed
147 unmodified lines
148 cmd Cmd149 subs = make(subManager)150 cmds = make(chan Cmd)151 msgs = make(chan Msg)152 errs = make(chan error)153 done = make(chan struct{})154 linesRendered int155 )156
18 unmodified lines
175 // as a subscription, but it blocks nicely and seems to be a common enough176 // need that we're enabling it by default.177 go func() {178 for {178 msg, _ := ReadKey(os.Stdin)179 msg, err := ReadKey(os.Stdin)180 if err != nil {181 errs <- err182 }183 msgs <- KeyMsg(msg)184 }185 }()186
18 unmodified lines
205206 // Handle updates and draw207 for {208 select {209 case err := <-errs:210 close(done)211 return err212 case msg := <-msgs:213214 // Handle quit message215 if _, ok := msg.(quitMsg); ok {
118 unmodified lines