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 simple library for writing platform independent terminal applications. It tries to follow the C++ 'Zero-overhead principle' and its headers only include C++ ones. It works on Windows, MacOS and Linux and offers a simple
13
+
programming interface. It
14
+
supports colors, keyboard input and has all the basic features to write any terminal application. On windows the library automatically allocate a console on GUI application and set up cin, cout, cerr etc...
15
+
16
+
## Minimal example
17
+
18
+
The minimal Hello World is as simple as :
19
+
20
+
```cpp
21
+
#include"cpp-terminal/io.hpp"
22
+
23
+
#include<iostream>
24
+
25
+
intmain()
26
+
{
27
+
std::cout << "\033[31mHello world !\033[0m" << std::endl;
28
+
return 0;
29
+
}
30
+
```
31
+
32
+
or
33
+
34
+
```cpp
35
+
#include"cpp-terminal/io.hpp"
36
+
#include"cpp-terminal/color.hpp"
37
+
38
+
#include<iostream>
39
+
40
+
intmain()
41
+
{
42
+
std::cout << Term::color_fg(Term::Color::Name::Red)<<"Hello world !"<<color_fg(Term::Color::Name::Default)<< std::endl;
43
+
return 0;
44
+
}
45
+
```
46
+
47
+
On windows, creating a console or attaching console to a GUI application can be done easily :
48
+
49
+
```cpp
50
+
#include"cpp-terminal/io.hpp"
51
+
#include"cpp-terminal/color.hpp"
52
+
53
+
#include<iostream>
54
+
55
+
int __stdcall WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show)
56
+
{
57
+
std::cout << Term::color_fg(Term::Color::Name::Red)<<"Hello world !"<<color_fg(Term::Color::Name::Default)<< std::endl;
58
+
return 0;
59
+
}
60
+
```
15
61
16
62
Until 2021, CPP-Terminal used to be a single header library. Now, CPP-Terminal consists out of multiple small and usage oriented headers:
63
+
17
64
- `cpp-terminal/base.hpp`: everything for basic Terminal control
18
65
- `cpp-terminal/input.hpp`: functions for gathering input
19
66
- `cpp-terminal/prompt.hpp`: some variations of different prompts
20
67
- `cpp-terminal/window.hpp`: a fully managed terminal window for terminal user interfaces (TUI)
21
68
- `cpp-terminal/version.hpp`: macros with cpp-terminal's version number
22
69
23
70
The library uses private header for platform dependent code:
71
+
24
72
- `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