//! The [`Console`] works as a virtual shell that renders on screen all output of `stdout`. As such, it is useful as a basic interface to show info to the user,
//! such as in simple "Hello World" applications or more complex software that does not need much user interaction.
//!
//! Have a look at [`Soc::redirect_to_3dslink()`](crate::services::soc::Soc::redirect_to_3dslink) for a better alternative when debugging applications.
usestd::cell::RefMut;
usestd::cell::RefMut;
usestd::default::Default;
usestd::default::Default;
@ -9,10 +14,10 @@ use crate::services::gfx::Screen;
/// If you'd like to see live `stdout` output while running the application but can't/don't want to show the text on the 3DS itself,
/// If you'd like to see live `stdout` output while running the application but cannnot/do not want to show the text on the 3DS itself,
/// you can try using [`Soc::redirect_to_3dslink`](crate::services::soc::Soc::redirect_to_3dslink) while activating the `--server` flag for `3dslink` (also supported by `cargo-3ds`).
/// you can try using [`Soc::redirect_to_3dslink`](crate::services::soc::Soc::redirect_to_3dslink) while activating the `--server` flag for `3dslink` (also supported by `cargo-3ds`).
/// More info in the `cargo-3ds` docs.
/// More info in the `cargo-3ds` docs.
#[doc(alias = "PrintConsole")]
#[doc(alias = "PrintConsole")]
@ -30,13 +35,37 @@ pub struct Console<'screen> {
}
}
impl<'screen>Console<'screen>{
impl<'screen>Console<'screen>{
/// Initialize a console on the chosen screen, overwriting whatever was on the screen
/// Initialize a console on the chosen screen.
/// previously (including other consoles). The new console is automatically selected for
/// printing.
///
///
/// # Notes
/// # Notes
///
///
/// This operation overwrites whatever was on the screen before the inizialization (including other [`Console`]s)
/// and changes the [`FramebufferFormat`](crate::services::gspgpu::FramebufferFormat) of the selected screen to better suit the [`Console`].
///
/// The new console is automatically selected for printing.
///
/// [`Console`] automatically takes care of flushing and swapping buffers for its screen when printing.
/// [`Console`] automatically takes care of flushing and swapping buffers for its screen when printing.
///
/// # Example
///
/// ```no_run
/// # use std::error::Error;
/// # fn main() -> Result<(), Box<dyn Error>> {
/// #
/// use ctru::services::gfx::Gfx;
/// use ctru::console::Console;
///
/// // Initialize graphics.
/// let gfx = Gfx::new()?;
///
/// // Create a `Console` that takes control of the upper LCD screen.
/// let top_console = Console::new(gfx.top_screen.borrow_mut());