Moves the cursor to beginning of the next line, scrolling the console if necessary. Does not clear nor draw the cursor.
(&mut self)
| 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. |
no test coverage detected