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...
PrintConsole * | consoleGetDefault (void)
| Gets a pointer to the console with the default values. More...
PrintConsole * | consoleSelect (PrintConsole *console)
| Make the specified console the render target. More...
PrintConsole * | consoleInit (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:

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

## Enumeration Type Documentation

## debugDevice

enum 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

  device | The 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
| ) |  |

Initialise the console.

Parameters

  screen | The screen to use for the console.
  console | A pointer to the console data to initialize (if it's NULL, the default console will be used).

Returns
  A pointer to the current console.

Examples
  app_launch/source/main.c, audio/filters/source/main.c, audio/mic/source/main.c, audio/streaming/source/main.c, camera/image/source/main.c, camera/video/source/main.c, get_system_language/source/main.c, graphics/bitmap/24bit-color/source/main.c, graphics/gpu/gpusprites/source/main.c, graphics/gpu/lenny/source/main.c, graphics/gpu/mipmap_fog/source/main.c, graphics/gpu/particles/source/main.c, graphics/gpu/proctex/source/main.c, graphics/gpu/toon_shading/source/main.c, graphics/printing/both-screen-text/source/main.c, graphics/printing/colored-text/source/main.c, graphics/printing/hello-world/source/main.c, graphics/printing/multiple-windows-text/source/main.c, input/read-controls/source/main.c, input/software-keyboard/source/main.c, input/touch-screen/source/main.c, libapplet_launch/source/main.c, mvd/source/main.c, network/boss/source/main.c, network/http/source/main.c, network/http_post/source/main.c, network/sockets/source/sockets.c, network/sslc/source/ssl.c, network/uds/source/uds.c, nfc/source/main.c, romfs/source/main.c, threads/event/source/main.c, threads/thread-basic/source/main.c, and time/rtc/source/main.c.

## consoleSelect()

PrintConsole* consoleSelect | ( | PrintConsole * | console | ) |

Make the specified console the render target.

Parameters

  console | A 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

  console | Pointer to the console to update, if NULL it will update the current console.
  font | The font to load.

## consoleSetWindow()

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

Sets the print window.

Parameters

  console | Console to set, if NULL it will set the current console window.
  x | X location of the window.
  y | Y location of the window.
  width | Width of the window.
  height | Height of the window.

Examples
  graphics/printing/multiple-windows-text/source/main.c.