Overview of CPP-Terminal
masterncurses.repository·master·Indexed 20 days ago
https://github.com/jupyter-xeus/cpp-terminalA lightweight, dependency-free C++ library for building cross-platform terminal applications and TUIs. It provides a unified API for colors, keyboard input, and window management across Windows 10+, Linux, and MacOS, serving as a maintainable alternative to ncurses.
ncurses.CPP-Terminal is organized into several small, usage-oriented headers rather than a single monolithic file:
cpp-terminal/input.hpp: Functions for gathering keyboard input.cpp-terminal/prompt.hpp: Various prompt implementations.cpp-terminal/window.hpp: A fully managed terminal window system for Terminal User Interfaces (TUI).cpp-terminal/version.hpp: Macros containing the library version number.cpp-terminal/terminal.hpp: Core terminal functionality.cpp-terminal/color.hpp: Color and styling utilities.On Windows, you can create or attach a console from a GUI application by using a WinMain entry point and including windows.h.
#include "cpp-terminal/terminal.hpp"
#include "cpp-terminal/color.hpp"
#include <iostream>
#include <windows.h>
int __stdcall WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show)
{
std::cout << Term::color_fg(Term::Color::Name::Red) << "Hello world !" << Term::color_fg(Term::Color::Name::Default) << std::endl;
return 0;
}You can use CPP-Terminal to add color to your terminal output. You can either use raw ANSI escape codes (which terminal.hpp helps activate) or use the provided Term::color_fg API with Term::Color::Name.
#include "cpp-terminal/terminal.hpp"
#include "cpp-terminal/color.hpp"
#include <iostream>
int main()
{
std::cout << Term::color_fg(Term::Color::Name::Red) << "Hello world !" << Term::color_fg(Term::Color::Name::Default) << std::endl;
}CPP-Terminal supports the following platforms and C++ standards:
| Platform | Supported Versions | Arch | Compiler | C++ Standard |
|---|---|---|---|---|
| Windows | 10+ | x86, x86_64 | MSVC 2019/2022, clang | 11, 14, 17, 20 |
| Windows (MSYS2) | All | x86, x86_64 | ucrt, clang, mingw | 11, 14, 17, 20 |
| MacOS | 11, 12 | - | xcode, gcc | 11, 14, 17, 20 |
| Linux | All | x86_64 | GCC 4.7+, Clang 3.5+ | 11, 14, 17, 20 |
Note: Windows versions prior to Windows 10 are not supported because they lack the Win32 API functionality for 'raw mode' and ANSI support.