chore: Add course material
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include <conio.h>
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
using std::string;
|
||||
|
||||
#include "Screen.h"
|
||||
|
||||
namespace {
|
||||
HANDLE hStdout = 0;
|
||||
}
|
||||
|
||||
void Screen::write(string s, int x, int y, int color) {
|
||||
if (hStdout == 0) {
|
||||
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
}
|
||||
|
||||
COORD screenPos;
|
||||
screenPos.X = x;
|
||||
screenPos.Y = y;
|
||||
|
||||
unsigned long ln;
|
||||
|
||||
static unsigned short attrib[80];
|
||||
|
||||
for (unsigned int i = 0; i < s.length(); ++i) {
|
||||
attrib[i] = color;
|
||||
}
|
||||
|
||||
WriteConsoleOutputAttribute(hStdout, attrib, s.length(), screenPos, &ln);
|
||||
|
||||
WriteConsoleOutputCharacter(hStdout, s.c_str(), s.length(), screenPos, &ln);
|
||||
}
|
||||
Reference in New Issue
Block a user