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

Method open_line

std/src/console/graphics.rs:424–447  ·  view source on GitHub ↗

Moves the cursor to beginning of the next line, scrolling the console if necessary. Does not clear nor draw the cursor.

(&mut self)

Source from the content-addressed store, hash-verified

422 ///
423 /// Does not clear nor draw the cursor.
424 fn open_line(&mut self) -> io::Result<()> {
425 if self.cursor_pos.y < self.size_chars.y - 1 {
426 self.cursor_pos.x = 0;
427 self.cursor_pos.y += 1;
428 return Ok(());
429 }
430
431 let text_height: u16 = self.size_chars.y.clamped_mul(self.glyph_size.height);
432 let x1y1 = PixelsXY::new(0, self.glyph_size.height.clamped_into());
433 let x2y2 = PixelsXY::new(0, 0);
434 let size = SizeInPixels::new(self.size_pixels.width, text_height - self.glyph_size.height);
435
436 self.raster_ops.set_draw_color(self.bg_color);
437 self.raster_ops.move_pixels(x1y1, x2y2, size)?;
438 if text_height < self.size_pixels.height {
439 let xy = PixelsXY::new(0, text_height.clamped_into());
440 let size =
441 SizeInPixels::new(self.size_pixels.width, self.size_pixels.height - text_height);
442 self.raster_ops.draw_rect_filled(xy, size)?;
443 }
444
445 self.cursor_pos.x = 0;
446 Ok(())
447 }
448
449 /// Renders the given text at the current cursor position, with wrapping and
450 /// scrolling if necessary.

Callers 2

raw_write_wrappedMethod · 0.80
printMethod · 0.80

Calls 5

clamped_mulMethod · 0.80
clamped_intoMethod · 0.80
set_draw_colorMethod · 0.45
move_pixelsMethod · 0.45
draw_rect_filledMethod · 0.45

Tested by

no test coverage detected