MCPcopy Create free account
hub / github.com/endbasic/endbasic / new

Method new

std/src/console/graphics.rs:340–376  ·  view source on GitHub ↗

Initializes a new graphical console.

(
        input_ops: IO,
        raster_ops: RO,
        audio_ops: AO,
        default_fg_color: Option<u8>,
        default_bg_color: Option<u8>,
    )

Source from the content-addressed store, hash-verified

338{
339 /// Initializes a new graphical console.
340 pub fn new(
341 input_ops: IO,
342 raster_ops: RO,
343 audio_ops: AO,
344 default_fg_color: Option<u8>,
345 default_bg_color: Option<u8>,
346 ) -> io::Result<Self> {
347 let info = raster_ops.get_info();
348
349 let default_fg_color = default_fg_color.unwrap_or(DEFAULT_FG_COLOR);
350 let default_bg_color = default_bg_color.unwrap_or(DEFAULT_BG_COLOR);
351
352 let mut console = Self {
353 input_ops,
354 raster_ops,
355 audio_ops,
356 size_pixels: info.size_pixels,
357 glyph_size: info.glyph_size,
358 size_chars: info.size_chars,
359 cursor_pos: CharsXY::default(),
360 cursor_visible: true,
361 cursor_backup: None,
362 default_fg_color,
363 default_bg_color,
364 ansi_bg_color: None,
365 ansi_fg_color: None,
366 bg_color: ansi_color_to_rgb(default_bg_color),
367 fg_color: ansi_color_to_rgb(default_fg_color),
368 alt_backup: None,
369 sync_enabled: true,
370 };
371
372 console.set_color(console.ansi_fg_color, console.ansi_bg_color)?;
373 console.clear(ClearType::All)?;
374
375 Ok(console)
376 }
377
378 /// Renders any buffered changes to the backing surface.
379 fn present_canvas(&mut self) -> io::Result<()> {

Callers

nothing calls this directly

Calls 4

ansi_color_to_rgbFunction · 0.85
get_infoMethod · 0.45
set_colorMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected