Browse Source

Console requires mutable Screen

pull/22/head
Andrea Ciliberti 3 years ago
parent
commit
526f7cc25e
  1. 8
      ctru-rs/src/console.rs

8
ctru-rs/src/console.rs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
use std::cell::Ref;
use std::cell::RefMut;
use std::default::Default;
use ctru_sys::{consoleClear, consoleInit, consoleSelect, consoleSetWindow, PrintConsole};
@ -7,21 +7,21 @@ use crate::gfx::Screen; @@ -7,21 +7,21 @@ use crate::gfx::Screen;
pub struct Console<'screen> {
context: Box<PrintConsole>,
screen: Ref<'screen, dyn Screen>,
screen: RefMut<'screen, dyn Screen>,
}
impl<'screen> Console<'screen> {
/// Initialize a console on the chosen screen, overwriting whatever was on the screen
/// previously (including other consoles). The new console is automatically selected for
/// printing.
pub fn init(screen: Ref<'screen, dyn Screen>) -> Self {
pub fn init(screen: RefMut<'screen, dyn Screen>) -> Self {
let mut context = Box::new(PrintConsole::default());
unsafe { consoleInit(screen.as_raw(), context.as_mut()) };
Console {
context,
_screen: screen,
screen,
}
}

Loading…
Cancel
Save