Struct TerminalBuilder

Source
pub struct TerminalBuilder { /* private fields */ }
Expand description

Builder for configuring and creating a Terminal.

Provides a fluent API for terminal configuration with sensible defaults. The terminal will use the default embedded font atlas unless explicitly configured.

§Examples

// Simple terminal with default configuration
use beamterm_renderer::{FontAtlas, FontAtlasData, Terminal};

let terminal = Terminal::builder("#canvas").build()?;

// Terminal with custom font atlas
let atlas = FontAtlasData::from_binary(unimplemented!(".atlas data"))?;
let terminal = Terminal::builder("#canvas")
    .font_atlas(atlas)
    .fallback_glyph("X".into())
    .build()?;

Implementations§

Source§

impl TerminalBuilder

Source

pub fn font_atlas(self, atlas: FontAtlasData) -> Self

Sets a custom font atlas for the terminal.

By default, the terminal uses an embedded font atlas. Use this method to provide a custom atlas with different fonts, sizes, or character sets.

Source

pub fn fallback_glyph(self, glyph: &str) -> Self

Sets the fallback glyph for missing characters.

When a character is not found in the font atlas, this glyph will be displayed instead. Defaults to a space character if not specified.

Source

pub fn canvas_padding_color(self, color: u32) -> Self

Sets the background color for the canvas area outside the terminal grid.

When the canvas dimensions don’t align perfectly with the terminal cell grid, there may be unused pixels around the edges. This color fills those padding areas to maintain a consistent appearance.

Source

pub fn mouse_input_handler<F>(self, callback: F) -> Self
where F: FnMut(TerminalMouseEvent, &TerminalGrid) + 'static,

Sets a callback for handling terminal mouse input events.

Source

pub fn default_mouse_input_handler( self, selection_mode: SelectionMode, trim_trailing_whitespace: bool, ) -> Self

Sets a default selection handler for mouse input events. Left button selects text, Ctrl/Cmd + C copies the selected text to the clipboard.

Source

pub fn build(self) -> Result<Terminal, Error>

Builds the terminal with the configured options.

Auto Trait Implementations§

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.