A lightweight, cross-platform C++ library for creating rich terminal applications with color support, cursor manipulation, and asynchronous operations. Works seamlessly on Windows and UNIX-like systems.
- Installation
- Basic Usage
- Text Styling
- Colors
- Terminal Operations
- Input Handling
- Asynchronous Operations
- Reference Charts
Include the header file in your project:
#include "Terminal.hpp"Compile with:
g++ -std=c++17 your_file.c++ -o your_programNo special setup or configuration is required.
Basic printing operations:
printer.println("Hello, Terminal++!");Chain multiple operations:
printer.setTextColor(Color::Blue)
.setBackgroundColor(Color::White)
.println("Styled text!");Available text styles through the TextStyle class:
TextStyle::Normal- Default text styleTextStyle::Bold- Bold weight textTextStyle::Dim- Dimmed text intensityTextStyle::Italic- Italic textTextStyle::Underline- Underlined textTextStyle::Blink- Blinking textTextStyle::Reverse- Reversed foreground/background colorsTextStyle::Hidden- Hidden textTextStyle::Strike- Strikethrough text
Available through the Color class:
Color::BlackColor::RedColor::GreenColor::YellowColor::BlueColor::MagentaColor::CyanColor::WhiteColor::Reset- Resets both text and background colors to terminal defaults
Use any color from 0 to 255:
printer.setTextColor(42) // Text color
.setBackgroundColor(200); // Background colorprinter.setTextColor(Color::Rgb(94, 60, 108)) // purple color
.println("Termina++ in purple!");Clear operations available through ClearType enum:
ClearType::All- Clear screen and historyClearType::Purge- Clear visible screen onlyClearType::Line- Clear current line
Example:
Terminal::clearScreen(ClearType::All);Cursor::moveTo(10, 5);Coordinates start at [1, 1] in the top-left corner of the terminal.
Cursor::hideCursor();Cursor::showCursor();Cursor::Default- the default cursor shape used by the userCursor::BlinkingBlock- a blinking block█Cursor::SteadyBlock- a non blinking blockCursor::BlinkingUnderline- a blinking underline_Cursor::SteadyUnderline- a non blinking underlineCursor::BlinkingBar- a blinking bar|Cursor::SteadyBar- a non blinking bar
Change cursor style
Cursor::setStyle(Cursor::BlinkingUnderline);auto [width, height] = Terminal::size();if (term.isResized()) {/*Handle resize*/}int newWidth, newHeight;
term.isResized(newWidth, newHeight);Terminal::setTitle("My Terminal App");Terminal::sleep(1000); // Sleep for 1 secondTerminal::reset();Resets all the terminal's attributes
- Backspace:
keyCode::Backspace - Enter:
keyCode::Enter - Escape:
keyCode::Esc - Tab:
keyCode::Tab - Space:
keyCode::Space - ArrowKeys
char c = Input::getChar();Gets a character from unbuffered input.
std::string str = Input::getString("Enter text: ");std::string line = Input::getLine("Enter a line: ");if (Terminal::keyPressed()) {/*Handle key press*/}Run background task:
term.nonBlock([]() {
printer.println("Processing...")
.setTextColor(Color::Green)
.println("Task complete!");
Terminal::sleep(1000);
});Wait for completion [optional]:
term.awaitCompletion();All background threads are automatically joined when the Terminal instance is destroyed.
For complete working examples - see the examples directory
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

