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::{FontAtlasData, Terminal};
let terminal = Terminal::builder("#canvas").build().unwrap();
// Terminal with custom font atlas
let atlas = FontAtlasData::from_binary(unimplemented!(".atlas data")).unwrap();
let terminal = Terminal::builder("#canvas")
.font_atlas(atlas)
.fallback_glyph("X".into())
.build().unwrap();Implementations§
Source§impl TerminalBuilder
impl TerminalBuilder
Sourcepub fn font_atlas(self, atlas: FontAtlasData) -> Self
pub fn font_atlas(self, atlas: FontAtlasData) -> Self
Sets a custom static 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.
Static atlases are pre-generated using the beamterm-atlas CLI tool and
loaded from binary .atlas files. They provide consistent rendering but
require the character set to be known at build time.
For dynamic glyph rasterization at runtime, see dynamic_font_atlas.
Sourcepub fn dynamic_font_atlas(self, font_family: &[&str], font_size: f32) -> Self
pub fn dynamic_font_atlas(self, font_family: &[&str], font_size: f32) -> Self
Configures the terminal to use a dynamic font atlas.
Unlike static atlases, the dynamic atlas rasterizes glyphs on-demand using the browser’s Canvas API. This enables:
- Runtime font selection without pre-generation
- Support for any system font available in the browser
- Automatic handling of unpredictable Unicode content
§Parameters
font_family- Font family names in priority order (e.g.,&["JetBrains Mono", "Fira Code"])font_size- Font size in pixels
For pre-generated atlases with fixed character sets, see font_atlas.
Sourcepub fn debug_dynamic_font_atlas(
self,
font_family: &[&str],
font_size: f32,
pattern: DebugSpacePattern,
) -> Self
pub fn debug_dynamic_font_atlas( self, font_family: &[&str], font_size: f32, pattern: DebugSpacePattern, ) -> Self
Configures the terminal to use a dynamic font atlas with debug space pattern.
This is the same as dynamic_font_atlas, but replaces
the space glyph with a checkered pattern for validating pixel-perfect rendering.
§Parameters
font_family- Font family names in priority orderfont_size- Font size in pixelspattern- The checkered pattern to use (1px or 2x2 pixels)
Sourcepub fn fallback_glyph(self, glyph: &str) -> Self
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.
Sourcepub fn canvas_padding_color(self, color: u32) -> Self
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.
Sourcepub fn enable_debug_api(self) -> Self
pub fn enable_debug_api(self) -> Self
Enables the debug API that will be exposed to the browser console.
When enabled, a debug API will be available at window.__beamterm_debug
with methods like getMissingGlyphs() for inspecting the terminal state.
Sourcepub fn mouse_input_handler<F>(self, callback: F) -> Self
pub fn mouse_input_handler<F>(self, callback: F) -> Self
Sets a callback for handling terminal mouse input events.
Sourcepub fn default_mouse_input_handler(
self,
selection_mode: SelectionMode,
trim_trailing_whitespace: bool,
) -> Self
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.