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

Struct Program

tea.go:434–560  ·  view source on GitHub ↗

Program is a terminal user interface.

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected