-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathprint.cpp
More file actions
41 lines (36 loc) · 901 Bytes
/
Copy pathprint.cpp
File metadata and controls
41 lines (36 loc) · 901 Bytes
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
#include <windows.h>
#include "print.h"
void print::set_color(const int forg_col)
{
const auto h_std_out = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(h_std_out, &csbi))
{
const WORD w_color = (csbi.wAttributes & 0xF0) + (forg_col & 0x0F);
SetConsoleTextAttribute(h_std_out, w_color);
}
}
void print::set_text(const char* text, const int color)
{
set_color(color);
printf(static_cast<const char*>(text));
set_color(White);
}
void print::set_error(const char* text)
{
set_color(Red);
printf(static_cast<const char*>(text));
set_color(White);
}
void print::set_warning(const char* text)
{
set_color(Yellow);
printf(static_cast<const char*>(text));
set_color(White);
}
void print::set_ok(const char* text)
{
set_color(Green);
printf(static_cast<const char*>(text));
set_color(White);
}