-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_extra.cpp
More file actions
54 lines (47 loc) · 1.66 KB
/
server_extra.cpp
File metadata and controls
54 lines (47 loc) · 1.66 KB
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
#include "server.h"
#include <thread>
#include <chrono>
//This is the definition for hide cursor()
//This hides the cursor for better aesthetics
void server::hideCursor()
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
GetConsoleCursorInfo(consoleHandle, &cursorInfo);
cursorInfo.bVisible = false;
SetConsoleCursorInfo(consoleHandle, &cursorInfo);
}
//This would show the cursor after being hidden by the hideCursor()
void server::showCursor()
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
GetConsoleCursorInfo(consoleHandle, &cursorInfo);
cursorInfo.bVisible = true;
SetConsoleCursorInfo(consoleHandle, &cursorInfo);
}
//This would show the url in the console
void server::port_view()
{
std::cout<< "http://localhost:"<< DEFAULT_PORT << "/"<<std::endl;
url += "http://localhost:" DEFAULT_PORT "/";
}
//This would open the browser in the default browser
void server::port_open()
{
ShellExecute(NULL,"open",url.c_str(),NULL,NULL,SW_SHOWNORMAL);
}
// This is a listening animation
// WARNING: As of now It is buggy
void server::loading_animation() {
while (true) {
std::cout << "\rListening" << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::cout << "\rListening." << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::cout << "\rListening.." << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::cout << "\rListening..." << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}