MCPcopy Index your code
hub / github.com/endbasic/endbasic / setup

Function setup

sdl/src/lib.rs:101–121  ·  view source on GitHub ↗

Creates an SDL console host and factory based on the given `spec`.

(
    spec: &mut ConsoleSpec<'_>,
    signals_tx: Sender<Signal>,
    fonts: &Fonts,
)

Source from the content-addressed store, hash-verified

99
100/// Creates an SDL console host and factory based on the given `spec`.
101pub fn setup(
102 spec: &mut ConsoleSpec<'_>,
103 signals_tx: Sender<Signal>,
104 fonts: &Fonts,
105) -> io::Result<(Box<dyn ConsoleHost>, Box<dyn ConsoleFactory>)> {
106 let resolution: Resolution = spec.take_keyed_flag("resolution")?.unwrap_or_else(|| {
107 let width = NonZeroU32::new(DEFAULT_RESOLUTION_PIXELS.0).unwrap();
108 let height = NonZeroU32::new(DEFAULT_RESOLUTION_PIXELS.1).unwrap();
109 Resolution::Windowed((width, height))
110 });
111
112 let default_fg_color = spec.take_keyed_flag::<u8>("fg_color")?;
113 let default_bg_color = spec.take_keyed_flag::<u8>("bg_color")?;
114
115 let font_name = spec.take_keyed_flag_str("font").unwrap_or(FONT_VGA8X16.name);
116 let font = fonts.get(font_name)?;
117
118 let (host, factory) =
119 new_console_pair(resolution, default_fg_color, default_bg_color, font, signals_tx);
120 Ok((Box::from(host), Box::from(factory)))
121}

Callers 1

setup_sdl_consoleFunction · 0.85

Calls 4

new_console_pairFunction · 0.85
take_keyed_flagMethod · 0.80
take_keyed_flag_strMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected