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

Struct Program

tea.go:448–589  ·  view source on GitHub ↗

Program is a terminal user interface.

Source from the content-addressed store, hash-verified

446
447// Program is a terminal user interface.
448type Program struct {
449 // disableInput disables all input. This is useful for programs that
450 // don't need input, like a progress bar or a spinner.
451 disableInput bool
452
453 // disableSignalHandler disables the signal handler that Bubble Tea sets up
454 // for Programs. This is useful if you want to handle signals yourself.
455 disableSignalHandler bool
456
457 // disableCatchPanics disables the panic catching that Bubble Tea does by
458 // default. If panic catching is disabled the terminal will be in a fairly
459 // unusable state after a panic because Bubble Tea will not perform its usual
460 // cleanup on exit.
461 disableCatchPanics bool
462
463 // filter supplies an event filter that will be invoked before Bubble Tea
464 // processes a tea.Msg. The event filter can return any tea.Msg which will
465 // then get handled by Bubble Tea instead of the original event. If the
466 // event filter returns nil, the event will be ignored and Bubble Tea will
467 // not process it.
468 //
469 // As an example, this could be used to prevent a program from shutting
470 // down if there are unsaved changes.
471 //
472 // Example:
473 //
474 // func filter(m tea.Model, msg tea.Msg) tea.Msg {
475 // if _, ok := msg.(tea.QuitMsg); !ok {
476 // return msg
477 // }
478 //
479 // model := m.(myModel)
480 // if model.hasChanges {
481 // return nil
482 // }
483 //
484 // return msg
485 // }
486 //
487 // p := tea.NewProgram(Model{});
488 // p.filter = filter
489 //
490 // if _,err := p.Run(context.Background()); err != nil {
491 // fmt.Println("Error running program:", err)
492 // os.Exit(1)
493 // }
494 filter func(Model, Msg) Msg
495
496 // fps sets a custom maximum fps at which the renderer should run. If less
497 // than 1, the default value of 60 will be used. If over 120, the fps will
498 // be capped at 120.
499 fps int
500
501 // initialModel is the initial model for the program and is the only
502 // required field when creating a new program.
503 initialModel Model
504
505 // disableRenderer prevents the program from rendering to the terminal.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected