Skip to content

Commit 755f7f2

Browse files
authored
Merge pull request #244 from flagarde/readme
Readme
2 parents f24dfea + 57717c6 commit 755f7f2

File tree

3 files changed

+76
-11
lines changed

3 files changed

+76
-11
lines changed

README.md

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,65 @@
99
[![pre-commit](https://github.com/jupyter-xeus/cpp-terminal/actions/workflows/pre-commit-check.yml/badge.svg)](https://github.com/jupyter-xeus/cpp-terminal/actions/workflows/pre-commit-check.yml)
1010
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/jupyter-xeus/cpp-terminal/master.svg)](https://results.pre-commit.ci/latest/github/jupyter-xeus/cpp-terminal/maset)
1111

12-
`CPP-Terminal` is a small and simple library for writing platform independent terminal applications. It works on Windows, MacOS and Linux and offers a simple programming interface. It
13-
supports colors, keyboard input and has all the basic features to write any
14-
terminal application.
12+
`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 crossplatform 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.
13+
14+
## Hello World example
15+
16+
To write a simple Hello World program, all you need to do is:
17+
18+
```cpp
19+
#include "cpp-terminal/io.hpp"
20+
21+
#include <iostream>
22+
23+
int main()
24+
{
25+
std::cout << "\033[31mHello world !\033[0m" << std::endl;
26+
return 0;
27+
}
28+
```
29+
30+
or
31+
32+
```cpp
33+
#include "cpp-terminal/io.hpp"
34+
#include "cpp-terminal/color.hpp"
35+
36+
#include <iostream>
37+
38+
int main()
39+
{
40+
std::cout << Term::color_fg(Term::Color::Name::Red)<<"Hello world !"<<color_fg(Term::Color::Name::Default)<< std::endl;
41+
return 0;
42+
}
43+
```
44+
45+
On wndows you can simply create or attach a console through a GUI application by doing:
46+
47+
```cpp
48+
#include "cpp-terminal/io.hpp"
49+
#include "cpp-terminal/color.hpp"
50+
51+
#include <iostream>
52+
#include <windows.h>
53+
54+
int __stdcall WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show)
55+
{
56+
std::cout << Term::color_fg(Term::Color::Name::Red)<<"Hello world !"<<color_fg(Term::Color::Name::Default)<< std::endl;
57+
return 0;
58+
}
59+
```
1560
1661
Until 2021, CPP-Terminal used to be a single header library. Now, CPP-Terminal consists out of multiple small and usage oriented headers:
62+
1763
- `cpp-terminal/base.hpp`: everything for basic Terminal control
1864
- `cpp-terminal/input.hpp`: functions for gathering input
1965
- `cpp-terminal/prompt.hpp`: some variations of different prompts
2066
- `cpp-terminal/window.hpp`: a fully managed terminal window for terminal user interfaces (TUI)
2167
- `cpp-terminal/version.hpp`: macros with cpp-terminal's version number
2268
2369
The library uses private header for platform dependent code:
70+
2471
- `cpp-terminal/private/conversion.hpp`: Various conversions
2572
- `cpp-terminal/private/platform.hpp`: platform dependent code
2673
@@ -38,14 +85,14 @@ We have created serval examples to show possible use cases of CPP-Terminal and t
3885
3986
## Supported platforms
4087
41-
| Platform | Supported versions | Coverage by unit test |
42-
|-------------------|--------------------|-----------------------|
43-
| Windows | 10 and higher* | MSVC |
44-
| (Windows) MSYS2 | All supported | / |
45-
| (Windows) Cygwin | All supported | / |
46-
| (Windows) MinGW | All supoorted | / |
47-
| MacOS | All supported | Apple-clang |
48-
| Linux | All supported | GCC>= 5 Clang >= 3.6 |
88+
| Platform | Supported versions | Arch | Compiler | C++ standard |
89+
|:-----------------:|:------------------:|:----------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------:|:------------:|
90+
| Windows | 10 and higher* | x86, x86_64 | MSVC 2019, MSVC 2022, clang11, clang12, clang13, clang14, clang15, clang-cl | 11,14,17,20 |
91+
| (Windows) MSYS2 | All supported | x86, x86_64 | ucrt , clang, mingw | 11,14,17,20 |
92+
| MacOS | 11 | | xcode11.7 xcode12.4 xcode12.5.1 xcode13 gcc10 gcc11 gcc12 | 11,14,17,20 |
93+
| MacOS | 12 | | xcode13.1 xcode13.2 xcode13.3 xcode13.4 | 11,14,17,20 |
94+
| Linux | All supported | x86_64 | 4.7<=GCC<= 12 3.5<=Clang<=15 intel-oneapi | 11,14,17,20 |
95+
| 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 |
4996
5097
> 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.
5198

tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ doctest_discover_tests(test_terminal)
2929
add_executable(AttachConsole WIN32 attach_console.test.cpp)
3030
target_link_libraries(AttachConsole PRIVATE doctest::doctest cpp-terminal::cpp-terminal)
3131

32+
add_executable(AttachConsoleMinimal WIN32 attach_console_minimal.test.cpp)
33+
target_link_libraries(AttachConsoleMinimal PRIVATE doctest::doctest cpp-terminal::cpp-terminal)
34+
3235
add_executable(file.test file.test.cpp)
3336
target_link_libraries(file.test PRIVATE doctest::doctest cpp-terminal::cpp-terminal)
3437
doctest_discover_tests(file.test)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "cpp-terminal/color.hpp"
2+
#include "cpp-terminal/io.hpp"
3+
4+
#include <iostream>
5+
6+
#ifdef _WIN32
7+
#include <windows.h>
8+
int __stdcall WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show)
9+
#else
10+
int main()
11+
#endif
12+
{
13+
std::cout << Term::color_fg(Term::Color::Name::Red) << "Hello world !" << color_fg(Term::Color::Name::Default) << std::endl;
14+
return 0;
15+
}

0 commit comments

Comments
 (0)