Shellminator V3.0.1
Simple Terminal
โ€ขAll Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Example 004 Format Matrix

Table of Contents

Most modern terminal emulators support VT100 escape sequences. These sequences are special commands that allow you to manipulate various terminal elements, such as color, style, and cursor position. If you're interested in this topic, you can find a detailed explanation here.

The demo below isnโ€™t interactiveโ€”it simply showcases how you can format the Serial output.

Live Demo

This can be a very useful example if you want to test the capabilities of your terminal emulator. This clever little example simply tries out every combination of formatting settings so you can see what each one results in.

Whole Code

/*
* Created on Aug 10 2020
*
* Copyright (c) 2023 - Daniel Hajnal
* hajnal.daniel96@gmail.com
* This file is part of the Shellminator project.
* Modified 2023.05.13
*/
#include "Shellminator.hpp"
// Create a Shellminator object, and initialize it to use Serial
Shellminator shell( &Serial );
int format_table[] = {
};
int format_table_size = sizeof( format_table ) / sizeof( format_table[ 0 ] );
const char* bold_str = "Bold";
const char* low_int_str = "Low Intensity";
const char* italic_str = "Italic";
const char* underline_str = "Underline";
const char* blink_str = "Blink";
const char* reverse_str = "Reverse";
const char* background_str = "Background";
const char* invisible_str = "Invisible";
const char* name_table[] = {
bold_str,
low_int_str,
italic_str,
underline_str,
blink_str,
reverse_str,
background_str,
invisible_str
};
int color_table[] = {
};
int color_table_size = sizeof( color_table ) / sizeof( color_table[ 0 ] );
int background_color_table[] = {
};
// System init section.
void setup(){
Serial.begin(115200);
int x;
int y;
// Clear the terminal
shell.clear();
Serial.println( "--- Style Matrix ---");
Serial.println();
for( y = 0; y < format_table_size; y++ ){
for( x = 0; x < color_table_size; x++ ){
shell.format( &Serial, color_table[ x ], format_table[ y ] );
Serial.print( "X");
shell.format( &Serial, Shellminator::REGULAR, Shellminator::WHITE );
}
Serial.print( " " );
Serial.println( name_table[ y ] );
}
Serial.println();
Serial.println( "--- Background Matrix ---");
Serial.println();
for( y = 0; y < color_table_size; y++ ){
for( x = 0; x < color_table_size; x++ ){
shell.format( &Serial, color_table[ x ], background_color_table[ y ] );
Serial.print( "X");
shell.format( &Serial, Shellminator::REGULAR, Shellminator::WHITE );
}
Serial.println();
}
}
// Infinite loop.
void loop(){
}
Shellminator object.
@ BLINKING
Blinking text style.
@ BOLD
Bold text style.
@ BACKGROUND
Background text style.
@ LOW_INTENSITY
Low intensity text style.
@ UNDERLINE
Underline text style.
@ ITALIC
Italic text style.
@ REVERSE
Reverse text style.
@ REGULAR
Regular text style.
@ INVISIBLE
Invisible text style.
@ BG_YELLOW
Yellow text color.
@ BG_MAGENTA
Magenta text color.
@ BG_BLACK
Black text color.
@ BG_WHITE
White text color.
@ BG_RED
Red text color.
@ BG_CYAN
Cyane text color.
@ BG_BLUE
Blue text color.
@ BG_GREEN
Green text color.
@ YELLOW
Yellow text color.
@ GREEN
Green text color.
@ BLACK
Black text color.
@ WHITE
White text color.
@ RED
Red text color.
@ MAGENTA
Magenta text color.
@ CYAN
Cyane text color.
@ BLUE
Blue text color.