checkResize detects the current size of the output and informs the program via a WindowSizeMsg.
()
| 270 | // checkResize detects the current size of the output and informs the program |
| 271 | // via a WindowSizeMsg. |
| 272 | func (p *Program) checkResize() { |
| 273 | if p.ttyOutput == nil { |
| 274 | // can't query window size |
| 275 | return |
| 276 | } |
| 277 | |
| 278 | w, h, err := term.GetSize(p.ttyOutput.Fd()) |
| 279 | if err != nil { |
| 280 | select { |
| 281 | case <-p.ctx.Done(): |
| 282 | case p.errs <- err: |
| 283 | } |
| 284 | |
| 285 | return |
| 286 | } |
| 287 | |
| 288 | w, h = p.fallbackDimensions(w, h) |
| 289 | |
| 290 | p.width, p.height = w, h |
| 291 | p.Send(WindowSizeMsg{Width: w, Height: h}) |
| 292 | } |
| 293 | |
| 294 | // OpenTTY opens the running terminal's TTY for reading and writing. |
| 295 | func OpenTTY() (*os.File, *os.File, error) { |
no test coverage detected