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

Method draw_cursor

std/src/console/graphics.rs:387–403  ·  view source on GitHub ↗

Draws the cursor at the current position and saves the previous contents of the screen so that `clear_cursor` can restore them. Does not present the canvas.

(&mut self)

Source from the content-addressed store, hash-verified

385 ///
386 /// Does not present the canvas.
387 fn draw_cursor(&mut self) -> io::Result<()> {
388 if !self.cursor_visible {
389 return Ok(());
390 }
391
392 let x1y1 = self.cursor_pos.clamped_mul(self.glyph_size);
393
394 assert!(self.cursor_backup.is_none());
395 self.cursor_backup = Some(self.raster_ops.read_pixels(x1y1, self.glyph_size)?);
396
397 // TODO(jmmv): It would be nice to draw the cursor with alpha blending so that the letters
398 // under it are visible. This was done before in the HTML canvas but was lost when I added
399 // the GraphicsConsole abstraction. Maybe all RGB colors should switch to RGBA. Or maybe
400 // we should special-case the cursor drawing.
401 self.raster_ops.set_draw_color(self.fg_color);
402 self.raster_ops.draw_rect_filled(x1y1, self.glyph_size)
403 }
404
405 /// Clears the cursor at the current position by restoring the contents of the screen saved by
406 /// an earlier call to `draw_cursor`.

Callers 7

clearMethod · 0.80
leave_altMethod · 0.80
locateMethod · 0.80
move_within_lineMethod · 0.80
printMethod · 0.80
show_cursorMethod · 0.80
writeMethod · 0.80

Calls 4

clamped_mulMethod · 0.80
read_pixelsMethod · 0.45
set_draw_colorMethod · 0.45
draw_rect_filledMethod · 0.45

Tested by

no test coverage detected