libctru  v2.3.1
graphics/printing/colored-text/source/main.c
/*
Colored Text example made by Aurelio Mannara for libctru
This code was modified for the last time on: 12/12/2014 23:00 UTC+1
*/
#include <3ds.h>
#include <stdio.h>
int main(int argc, char **argv)
{
// Initialize services
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
//Move the cursor to row 15 and column 19 and then prints "Hello World!"
//To move the cursor you have to print "\x1b[r;cH", where r and c are respectively
//the row and column where you want your cursor to move
//The top screen has 30 rows and 50 columns
//The bottom screen has 30 rows and 40 columns
printf("\x1b[16;20HHello World!");
//Move the cursor to the top left corner of the screen
printf("\x1b[1;1H");
//Print a REALLY crappy poeam with colored text
//\x1b[cm set a SGR (Select Graphic Rendition) parameter, where c is the parameter that you want to set
//Please refer to http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes to see all the possible SGR parameters
//As of now libctru support only these parameters:
//Reset (0), Half bright colors (2), Reverse (7), Text color (30-37) and Background color (40-47)
printf("Roses are \x1b[31mred\x1b[0m\n");
printf("Violets are \x1b[34mblue\x1b[0m\n");
printf("Lenny is our savior\n");
printf("Homebrew is his blessing\n\n");
//Black text on white background
//In this example we set two parameter in a single escape sequence by separating them by a semicolon
//\x1b[47;30m means that it will set a white background (47) and it will print white characters (30)
//In this we also could have used the
printf("\x1b[47;30mBlack text on white background\x1b[0m");
printf("\x1b[30;16HPress Start to exit.");
// Main loop
while (aptMainLoop())
{
//Scan all the inputs. This should be done once for each frame
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
u32 kDown = hidKeysDown();
if (kDown & KEY_START) break; // break in order to return to hbmenu
// Flush and swap framebuffers
//Wait for VBlank
}
// Exit services
return 0;
}
Central 3DS header.
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.
void gfxSwapBuffers(void)
Updates the configuration of both screens.
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
@ GFX_TOP
Top screen.
Definition: gfx.h:26
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
void gfxFlushBuffers(void)
Flushes the data cache for the current framebuffers.
#define gspWaitForVBlank()
Waits for VBlank.
Definition: gspgpu.h:151
@ KEY_START
Start.
Definition: hid.h:15
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
void hidScanInput(void)
Scans HID for input data.
uint32_t u32
32-bit unsigned integer
Definition: types.h:23