libctru  v2.4.1
Data Structures | Macros | Typedefs | Enumerations | Functions
console.h File Reference

3ds stdio support. More...

#include <3ds/types.h>
#include <3ds/gfx.h>

Go to the source code of this file.

Data Structures

struct  ConsoleFont
 A font struct for the console. More...
 
struct  PrintConsole
 Console structure used to store the state of a console render context. More...
 

Macros

#define CONSOLE_ESC(x)   "\x1b[" #x
 
#define CONSOLE_RESET   CONSOLE_ESC(0m)
 
#define CONSOLE_BLACK   CONSOLE_ESC(30m)
 
#define CONSOLE_RED   CONSOLE_ESC(31;1m)
 
#define CONSOLE_GREEN   CONSOLE_ESC(32;1m)
 
#define CONSOLE_YELLOW   CONSOLE_ESC(33;1m)
 
#define CONSOLE_BLUE   CONSOLE_ESC(34;1m)
 
#define CONSOLE_MAGENTA   CONSOLE_ESC(35;1m)
 
#define CONSOLE_CYAN   CONSOLE_ESC(36;1m)
 
#define CONSOLE_WHITE   CONSOLE_ESC(37;1m)
 
#define CONSOLE_COLOR_BOLD   (1<<0)
 Bold text.
 
#define CONSOLE_COLOR_FAINT   (1<<1)
 Faint text.
 
#define CONSOLE_ITALIC   (1<<2)
 Italic text.
 
#define CONSOLE_UNDERLINE   (1<<3)
 Underlined text.
 
#define CONSOLE_BLINK_SLOW   (1<<4)
 Slow blinking text.
 
#define CONSOLE_BLINK_FAST   (1<<5)
 Fast blinking text.
 
#define CONSOLE_COLOR_REVERSE   (1<<6)
 Reversed color text.
 
#define CONSOLE_CONCEAL   (1<<7)
 Concealed text.
 
#define CONSOLE_CROSSED_OUT   (1<<8)
 Crossed out text.
 
#define CONSOLE_FG_CUSTOM   (1<<9)
 Foreground custom color.
 
#define CONSOLE_BG_CUSTOM   (1<<10)
 Background custom color.
 

Typedefs

typedef bool(* ConsolePrint) (void *con, int c)
 A callback for printing a character.
 

Enumerations

enum  debugDevice {
  debugDevice_NULL ,
  debugDevice_SVC ,
  debugDevice_CONSOLE ,
  debugDevice_3DMOO = debugDevice_SVC
}
 Console debug devices supported by libnds. More...
 

Functions

void consoleSetFont (PrintConsole *console, ConsoleFont *font)
 Loads the font into the console. More...
 
void consoleSetWindow (PrintConsole *console, int x, int y, int width, int height)
 Sets the print window. More...
 
PrintConsoleconsoleGetDefault (void)
 Gets a pointer to the console with the default values. More...
 
PrintConsoleconsoleSelect (PrintConsole *console)
 Make the specified console the render target. More...
 
PrintConsoleconsoleInit (gfxScreen_t screen, PrintConsole *console)
 Initialise the console. More...
 
void consoleDebugInit (debugDevice device)
 Initializes debug console output on stderr to the specified device. More...
 
void consoleClear (void)
 Clears the screen by using iprintf("\x1b[2J");.
 

Detailed Description

3ds stdio support.

Provides stdio integration for printing to the 3DS screen as well as debug print functionality provided by stderr.

General usage is to initialize the console by:

consoleDemoInit()

or to customize the console usage by:

PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.

Enumeration Type Documentation

◆ debugDevice

Console debug devices supported by libnds.

Enumerator
debugDevice_NULL 

Swallows prints to stderr.

debugDevice_SVC 

Outputs stderr debug statements using svcOutputDebugString, which can then be captured by interactive debuggers.

debugDevice_CONSOLE 

Directs stderr debug statements to 3DS console window.

Function Documentation

◆ consoleDebugInit()

void consoleDebugInit ( debugDevice  device)

Initializes debug console output on stderr to the specified device.

Parameters
deviceThe debug device (or devices) to output debug print statements to.

◆ consoleGetDefault()

PrintConsole* consoleGetDefault ( void  )

Gets a pointer to the console with the default values.

This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit().

Returns
A pointer to the console with the default values.

◆ consoleInit()

PrintConsole* consoleInit ( gfxScreen_t  screen,
PrintConsole console 
)

◆ consoleSelect()

PrintConsole* consoleSelect ( PrintConsole console)

Make the specified console the render target.

Parameters
consoleA pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)).
Returns
A pointer to the previous console.
Examples
audio/filters/source/main.c, audio/streaming/source/main.c, graphics/printing/both-screen-text/source/main.c, and graphics/printing/multiple-windows-text/source/main.c.

◆ consoleSetFont()

void consoleSetFont ( PrintConsole console,
ConsoleFont font 
)

Loads the font into the console.

Parameters
consolePointer to the console to update, if NULL it will update the current console.
fontThe font to load.

◆ consoleSetWindow()

void consoleSetWindow ( PrintConsole console,
int  x,
int  y,
int  width,
int  height 
)

Sets the print window.

Parameters
consoleConsole to set, if NULL it will set the current console window.
xX location of the window.
yY location of the window.
widthWidth of the window.
heightHeight of the window.
Examples
graphics/printing/multiple-windows-text/source/main.c.