CPPConsole
Loading...
Searching...
No Matches
ansi.hpp
Go to the documentation of this file.
1#ifndef __CPP_CONSOLE_ANSI_HPP__
2#define __CPP_CONSOLE_ANSI_HPP__
3
4#ifdef __WIN32
5#include <Windows.h>
6#else
7#include <stdio.h>
8#include <sys/ioctl.h>
9#include <termios.h>
10#include <unistd.h>
11#endif
12
16namespace console {
23#ifdef __WIN32
24 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
25 DWORD consoleMode;
26 GetConsoleMode(hConsole, &consoleMode);
27 return consoleMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING;
28#else
29 return true;
30#endif
31}
32
36void enableANSI() {
37#ifdef __WIN32
38 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
39 DWORD consoleMode;
40 GetConsoleMode(hConsole, &consoleMode);
41 consoleMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
42 SetConsoleMode(hConsole, consoleMode);
43#endif
44}
45} // namespace console
46
47#endif
Namespace Containing all console commands.
Definition ansi.hpp:16
void enableANSI()
Enables ANSI for Windows environments.
Definition ansi.hpp:36
bool isANSIEnabled()
Checks if ANSI Codes are enable in windows.
Definition ansi.hpp:22