MCPcopy Create free account
hub / github.com/charmbracelet/bubbletea / checkResize

Method checkResize

tty.go:272–292  ·  view source on GitHub ↗

checkResize detects the current size of the output and informs the program via a WindowSizeMsg.

()

Source from the content-addressed store, hash-verified

270// checkResize detects the current size of the output and informs the program
271// via a WindowSizeMsg.
272func (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.
295func OpenTTY() (*os.File, *os.File, error) {

Callers 3

eventLoopMethod · 0.95
RestoreTerminalMethod · 0.95
listenForResizeMethod · 0.95

Calls 2

fallbackDimensionsMethod · 0.95
SendMethod · 0.95

Tested by

no test coverage detected