Skip to main content

ProgramOptions

Struct ProgramOptions 

Source
pub struct ProgramOptions<M: Model> {
Show 13 fields pub fps: u32, pub disable_renderer: bool, pub disable_signals: bool, pub disable_signal_handler: bool, pub disable_catch_panics: bool, pub width: usize, pub height: usize, pub filter: Option<EventFilter<M>>, pub input: Option<Box<dyn Read + Send + Sync>>, pub output: Option<Box<dyn Write + Send + Sync>>, pub environ: Option<Vec<(String, String)>>, pub color_profile: Option<ColorProfile>, pub context: Option<Context>,
}
Expand description

Program configuration options.

Fields§

§fps: u32

Target FPS framerate limit.

§disable_renderer: bool

Disable renderer (for daemon or headless usage).

§disable_signals: bool

Disable OS signal handling.

§disable_signal_handler: bool

Disable the signal handler that Bubble Tea sets up for programs.

§disable_catch_panics: bool

Disable the panic catching that Bubble Tea does by default.

§width: usize

Initial terminal width override.

§height: usize

Initial terminal height override.

§filter: Option<EventFilter<M>>

Optional event filter.

§input: Option<Box<dyn Read + Send + Sync>>

Input reader override; None means stdin.

§output: Option<Box<dyn Write + Send + Sync>>

Output writer override; None means stdout.

§environ: Option<Vec<(String, String)>>

Environment variables used by the program.

§color_profile: Option<ColorProfile>

Forced color profile.

§context: Option<Context>

External cancellation context.

Implementations§

Source§

impl<M: Model> ProgramOptions<M>

Source

pub fn with_context(self, ctx: Context) -> Self

WithContext lets you specify a context in which to run the Program. This is useful if you want to cancel the execution from outside. When a Program gets cancelled it will exit with an error ErrProgramKilled.

Source

pub fn with_output(self, output: Box<dyn Write + Send + Sync>) -> Self

WithOutput sets the output which, by default, is stdout. In most cases you won’t need to use this.

Source

pub fn with_input(self, input: Option<Box<dyn Read + Send + Sync>>) -> Self

WithInput sets the input which, by default, is stdin. In most cases you won’t need to use this. To disable input entirely pass None.

Source

pub fn with_environment(self, env: Vec<(String, String)>) -> Self

WithEnvironment sets the environment variables that the program will use. This is useful when the program is running in a remote session (e.g. SSH) and you want to pass the environment variables from the remote session to the program.

Source

pub fn without_signal_handler(self) -> Self

WithoutSignalHandler disables the signal handler that Bubble Tea sets up for Programs. This is useful if you want to handle signals yourself.

Source

pub fn without_catch_panics(self) -> Self

WithoutCatchPanics disables the panic catching that Bubble Tea does by default. If panic catching is disabled the terminal will be in a fairly unusable state after a panic because Bubble Tea will not perform its usual cleanup on exit.

Source

pub fn without_signals(self) -> Self

WithoutSignals will ignore OS signals. This is mainly useful for testing.

Source

pub fn without_renderer(self) -> Self

WithoutRenderer disables the renderer. When this is set output and log statements will be plainly sent to stdout (or another output if one is set) without any rendering and redrawing logic.

Source

pub fn with_filter(self, filter: EventFilter<M>) -> Self

WithFilter supplies an event filter that will be invoked before Bubble Tea processes a tea.Msg. The event filter can return any tea.Msg which will then get handled by Bubble Tea instead of the original event. If the event filter returns None, the event will be ignored and Bubble Tea will not process it.

Source

pub fn with_fps(self, fps: u32) -> Self

WithFPS sets a custom maximum FPS at which the renderer should run. If less than 1, the default value of 60 will be used. If over 120, the FPS will be capped at 120.

Source

pub fn with_color_profile(self, profile: ColorProfile) -> Self

WithColorProfile sets the color profile that the program will use.

Source

pub fn with_window_size(self, width: usize, height: usize) -> Self

WithWindowSize sets the initial size of the terminal window. This is useful when you need to set the initial size of the terminal window, for example during testing or when you want to run your program in a non-interactive environment.

Trait Implementations§

Source§

impl<M: Model> Default for ProgramOptions<M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for ProgramOptions<M>

§

impl<M> !UnwindSafe for ProgramOptions<M>

§

impl<M> Freeze for ProgramOptions<M>

§

impl<M> Send for ProgramOptions<M>

§

impl<M> Sync for ProgramOptions<M>

§

impl<M> Unpin for ProgramOptions<M>

§

impl<M> UnsafeUnpin for ProgramOptions<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.