-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelpers.c
75 lines (61 loc) · 1.44 KB
/
helpers.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "helpers.h"
SIZE *createSize();
/*
Cria uma posição
parameters: void
return: POSITION
*/
POSITION *createPosition(){
POSITION *position = (POSITION*) calloc(1, sizeof(POSITION));
position->x = 0;
position->y = 0;
return position;
}
/*
Cria uma dimensão
parameters: void
return: DIMENSION
*/
DIMENSION *createDimension(){
DIMENSION *dimension = (DIMENSION*) calloc(1, sizeof(DIMENSION));
dimension->width = 0;
dimension->height = 0;
return dimension;
}
/*
Posiciona o cursor do mouse numa posição indicada
parameters: unsigned short x, unsigned short y
return: void
*/
void gotoXY(unsigned short x, unsigned short y){
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coords = {x, y};
SetConsoleCursorPosition(hStdout, coords);
}
/*
Oculta o cursor
parameters: void
return: void
*/
void hideCursor(){
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor = {1, FALSE};
SetConsoleCursorInfo(hStdout, &cursor);
}
/*
Define o tamanho da janela
parameters: unsigned short width, unsigned short height
return: void
*/
void setWindowDimension(unsigned short width, unsigned short height){
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SMALL_RECT sr;
COORD consoleSize;
consoleSize.X = width;
consoleSize.Y = height;
sr.Top = sr.Left = 0;
sr.Right = width - 1;
sr.Bottom = height - 1;
SetConsoleWindowInfo(hStdout, TRUE, &sr);
SetConsoleScreenBufferSize(hStdout, consoleSize);
}