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

Method flush

tea.go:1383–1399  ·  view source on GitHub ↗

flush flushes the output buffer to the program output.

()

Source from the content-addressed store, hash-verified

1381
1382// flush flushes the output buffer to the program output.
1383func (p *Program) flush() error {
1384 p.mu.Lock()
1385 defer p.mu.Unlock()
1386
1387 if p.outputBuf.Len() == 0 {
1388 return nil
1389 }
1390 if p.logger != nil {
1391 p.logger.Printf("output: %q", p.outputBuf.String())
1392 }
1393 _, err := p.output.Write(p.outputBuf.Bytes())
1394 p.outputBuf.Reset()
1395 if err != nil {
1396 return fmt.Errorf("error writing to output: %w", err)
1397 }
1398 return nil
1399}
1400
1401// keepWriteErr remembers err as the error to return from [Program.Run] if it
1402// is the first error writing to the output. Later errors are dropped so they

Callers 4

restoreTerminalStateMethod · 0.95
drainQueryRepliesMethod · 0.95
RestoreTerminalMethod · 0.95
flushFrameMethod · 0.95

Calls 4

LenMethod · 0.80
PrintfMethod · 0.80
StringMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected