You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`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
+
intmain()
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
+
intmain()
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
+
```
15
60
16
61
Until 2021, CPP-Terminal used to be a single header library. Now, CPP-Terminal consists out of multiple small and usage oriented headers:
62
+
17
63
- `cpp-terminal/base.hpp`: everything for basic Terminal control
18
64
- `cpp-terminal/input.hpp`: functions for gathering input
19
65
- `cpp-terminal/prompt.hpp`: some variations of different prompts
20
66
- `cpp-terminal/window.hpp`: a fully managed terminal window for terminal user interfaces (TUI)
21
67
- `cpp-terminal/version.hpp`: macros with cpp-terminal's version number
22
68
23
69
The library uses private header for platform dependent code:
70
+
24
71
- `cpp-terminal/private/conversion.hpp`: Various conversions
> 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.
0 commit comments