-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscreen.cpp
More file actions
35 lines (29 loc) · 808 Bytes
/
Copy pathscreen.cpp
File metadata and controls
35 lines (29 loc) · 808 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
/*
Author: Jared Thomas
Date: Sunday, January 29, 2023
This module provides the platform-dependent clear screen command.
*/
#include "screen.h"
#ifdef PLATFORM_LINUX
#include <iostream>
#endif
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#endif
void clearScreen()
{
#ifdef PLATFORM_LINUX
std::cout << "\033[2J";
std::cout << "\033[1;1H";
#endif
#ifdef PLATFORM_WINDOWS
COORD tl = {0,0};
CONSOLE_SCREEN_BUFFER_INFO s;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(console, &s);
DWORD written, cells = s.dwSize.X * s.dwSize.Y;
FillConsoleOutputCharacter(console, ' ', cells, tl, &written);
FillConsoleOutputAttribute(console, s.wAttributes, cells, tl, &written);
SetConsoleCursorPosition(console, tl);
#endif
}