ProductPromotion
Logo

C++ Programming

made by https://0x3d.site

GitHub - jupyter-xeus/cpp-terminal: C++ library for writing multiplatform terminal applications
C++ library for writing multiplatform terminal applications - jupyter-xeus/cpp-terminal
Visit Site

GitHub - jupyter-xeus/cpp-terminal: C++ library for writing multiplatform terminal applications

GitHub - jupyter-xeus/cpp-terminal: C++ library for writing multiplatform terminal applications

Linux CI Windows CI MacOS CI docs CodeQL pre-commit pre-commit.ci status

CPP-Terminal is a small and dependency-free C++ library for writing platform independent terminal-based applications. It follows the "Zero-overhead principle" and limits externally included files to the C++ STL. Being cross-platform we are currently supporting Windows, Linux and MacOS and are providing an unified API across all platforms. Our main features are consisting of Colors, Keyboard input, terminal resize handling, as well as other common terminal functionality. It's also possible to open a managed terminal from a windows GUI application.

Hello World example

To write a simple Hello World program, all you need to do is:

#include "cpp-terminal/terminal.hpp"
#include <iostream>

int main()
{
  std::cout << "Just including terminal.hpp activate \033[31mcolor\033[0m !" << std::endl;
}

or

#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 !"<<color_fg(Term::Color::Name::Default)<< std::endl;
}

On windows you can simply create or attach a console through a GUI application by doing:

#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 !"<<color_fg(Term::Color::Name::Default)<< std::endl;
  return 0;
}

Until 2021, CPP-Terminal used to be a single header library. Now, CPP-Terminal consists out of multiple small and usage oriented headers:

  • cpp-terminal/input.hpp: functions for gathering input
  • cpp-terminal/prompt.hpp: some variations of different prompts
  • cpp-terminal/window.hpp: a fully managed terminal window for terminal user interfaces (TUI)
  • cpp-terminal/version.hpp: macros with cpp-terminal's version number

CPP-Terminal tries to be a small and simple replacement for ncurses. This approach keeps the code small and maintainable, but also easy to extend it's functionality. We limit ourselves to a subset of features that work on all supported platforms without needing to worry about style differences or other changes. Any application written with CPP-Terminal will work everywhere out of the box natively, without emulation or extra work. The small codebase makes CPP-Terminal easy to debug and extend, as well as understanding what happens behind the scenes in the library's core.

Examples

We have created serval examples to show possible use cases of CPP-Terminal and to get you started more quickly. Every example works natively on all platforms in the exact same way:

  • colors.cpp: basic color, style and unicode demo
  • kilo.cpp: the kilo text editor ported to C++ and CPP-Terminal instead of using Linux specific API
  • menu.cpp: An interactive menu using only the contents of cpp-terminal/base.hpp
  • menu_window.cpp: An interactive menu using the fully managed windowing system from cpp-terminal/window.hpp
  • keys.cpp: Interactively shows the keys pressed

Supported platforms

Platform Supported versions Arch Compiler C++ standard
Windows 10 and higher* x86, x86_64 MSVC 2019, MSVC 2022, clang11, clang12, clang13, clang14, clang15, clang-cl 11,14,17,20
(Windows) MSYS2 All supported x86, x86_64 ucrt , clang, mingw 11,14,17,20
MacOS 11 xcode11.7 xcode12.4 xcode12.5.1 xcode13 gcc10 gcc11 gcc12 11,14,17,20
MacOS 12 xcode13.1 xcode13.2 xcode13.3 xcode13.4 11,14,17,20
Linux All supported x86_64 4.7<=GCC<= 12 3.5<=Clang<=15 intel-oneapi 11,14,17,20
Linux (dockcross) All supported arm64 armv5 armv5-musl armv5-uclibc armv6 armv7a, mips, mipsel-lts, s390x, ppc64le, xtensa-uclibc, x86, x64, x64-clang, x64-tinycc 4.7<=GCC<= 12 3.5<=Clang<=15 11,14,17,20

Windows versions prior Windows 10 are missing the Win32 API functionality for entering the "raw mode" and therefore won't work. They are also lacking ANSI support. See #173 for adding support to prior windows versions for MSVC / Win32.

How to use

Adding CPP-Terminal to your own project is really easy. We have collected various ways with easy how-to's in our documentation.

Documentation

Contributing

Contributing to CPP-Terminal is highly appreciated and can be done in more ways than code. Extending it's functionality, reporting or fixing bugs and extending the documentations are just a few of them.

License

CPP-Terminal is licensed under the terms of the MIT License by Ondřej Čertík.

Projects using cpp-terminal

Similar Projects

Colors

Libraries to handle color output.

C++:

Drawing

JavaScript:

Prompt

Libraries to handle a prompt in terminals.

C and C++:

Python:

General TUI libraries

C and C++:

Python:

Go:

Rust:

JavaScript:

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory