-
Notifications
You must be signed in to change notification settings - Fork 3
/
util.h
54 lines (50 loc) · 1.22 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <windows.h>
#include <string>
#include <ctime>
#include <vector>
#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LIGHTGRAY 7
#define DARKGRAY 8
#define LIGHTBLUE 9
#define LIGHTGREEN 10
#define LIGHTCYAN 11
#define LUGHTRED 12
#define LIGHTMAGENTA 13
#define YELLOW 14
#define WHITE 15
namespace util
{
void ColorTo(unsigned short color)
{
HANDLE con = 0;
con = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(con, color);
}
void Null()
{
COORD topLeft = { 0, 0 };
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen;
DWORD written;
GetConsoleScreenBufferInfo(console, &screen);
FillConsoleOutputCharacterA(console, ' ', screen.dwSize.X * screen.dwSize.Y, topLeft, &written);
FillConsoleOutputAttribute(console, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE, screen.dwSize.X * screen.dwSize.Y, topLeft, &written);
SetConsoleCursorPosition(console, topLeft);
return;
}
void show()
{
ShowWindow(GetConsoleWindow(), SW_SHOW);
}
void hide()
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
}
}