MCPcopy
hub / github.com/charmbracelet/bubbletea / startRenderer

Method startRenderer

tea.go:1393–1422  ·  view source on GitHub ↗

startRenderer starts the renderer.

()

Source from the content-addressed store, hash-verified

1391
1392// startRenderer starts the renderer.
1393func (p *Program) startRenderer() {
1394 framerate := time.Second / time.Duration(p.fps)
1395 if p.ticker == nil {
1396 p.ticker = time.NewTicker(framerate)
1397 } else {
1398 // If the ticker already exists, it has been stopped and we need to
1399 // reset it.
1400 p.ticker.Reset(framerate)
1401 }
1402
1403 // Since the renderer can be restarted after a stop, we need to reset
1404 // the done channel and its corresponding sync.Once.
1405 p.once = sync.Once{}
1406
1407 // Start the renderer.
1408 p.renderer.start()
1409 go func() {
1410 for {
1411 select {
1412 case <-p.rendererDone:
1413 p.ticker.Stop()
1414 return
1415
1416 case <-p.ticker.C:
1417 _ = p.flush()
1418 _ = p.renderer.flush(false)
1419 }
1420 }
1421 }()
1422}
1423
1424// stopRenderer stops the renderer.
1425// If kill is true, the renderer will be stopped immediately without flushing

Callers 2

RunMethod · 0.95
RestoreTerminalMethod · 0.95

Calls 3

flushMethod · 0.95
startMethod · 0.65
flushMethod · 0.65

Tested by

no test coverage detected