checkResize detects the current size of the output and informs the program via a WindowSizeMsg.
()
| 107 | // checkResize detects the current size of the output and informs the program |
| 108 | // via a WindowSizeMsg. |
| 109 | func (p *Program) checkResize() { |
| 110 | if p.ttyOutput == nil { |
| 111 | // can't query window size |
| 112 | return |
| 113 | } |
| 114 | |
| 115 | w, h, err := term.GetSize(p.ttyOutput.Fd()) |
| 116 | if err != nil { |
| 117 | select { |
| 118 | case <-p.ctx.Done(): |
| 119 | case p.errs <- err: |
| 120 | } |
| 121 | |
| 122 | return |
| 123 | } |
| 124 | |
| 125 | p.width, p.height = w, h |
| 126 | p.Send(WindowSizeMsg{Width: w, Height: h}) |
| 127 | } |
| 128 | |
| 129 | // OpenTTY opens the running terminal's TTY for reading and writing. |
| 130 | func OpenTTY() (*os.File, *os.File, error) { |
no test coverage detected