-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUI.h
154 lines (133 loc) · 3.07 KB
/
UI.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef UI_HEADER
#define UI_HEADER
#if defined __unix__
#include <stdio.h>
#include <sys/ioctl.h>
#define clrscr() system("clear")
#define utf8() \
{}
#define C_B_BLACK 40
#define C_B_RED 41
#define C_B_GREEN 42
#define C_B_YELLOW 43
#define C_B_BLUE 44
#define C_B_MAGENTA 45
#define C_B_CYAN 46
#define C_B_WHITE 47
#define C_B_BBLACK 100
#define C_B_BRED 101
#define C_B_BGREEN 102
#define C_B_BYELLOW 103
#define C_B_BBLUE 104
#define C_B_BMAGENTA 105
#define C_B_BCYAN 106
#define C_B_BWHITE 107
#define C_F_BLACK 30
#define C_F_RED 31
#define C_F_GREEN 32
#define C_F_YELLOW 33
#define C_F_BLUE 34
#define C_F_MAGENTA 35
#define C_F_CYAN 36
#define C_F_WHITE 37
#define C_F_BBLACK 90
#define C_F_BRED 91
#define C_F_BGREEN 92
#define C_F_BYELLOW 93
#define C_F_BBLUE 94
#define C_F_BMAGENTA 95
#define C_F_BCYAN 96
#define C_F_BWHITE 97
#elif defined _WIN32
#include <conio.h>
#include <windows.h>
#define clrscr() system("cls")
#define utf8() SetConsoleOutputCP(CP_UTF8)
#define C_B_BLACK 0
#define C_B_RED 4
#define C_B_GREEN 2
#define C_B_YELLOW 6
#define C_B_BLUE 1
#define C_B_MAGENTA 5
#define C_B_CYAN 3
#define C_B_WHITE 7
#define C_B_BBLACK 8
#define C_B_BRED 12
#define C_B_BGREEN 10
#define C_B_BYELLOW 14
#define C_B_BBLUE 9
#define C_B_BMAGENTA 13
#define C_B_BCYAN 11
#define C_B_BWHITE 15
#define C_F_BLACK 0
#define C_F_RED 4
#define C_F_GREEN 2
#define C_F_YELLOW 6
#define C_F_BLUE 1
#define C_F_MAGENTA 5
#define C_F_CYAN 3
#define C_F_WHITE 7
#define C_F_BBLACK 8
#define C_F_BRED 12
#define C_F_BGREEN 10
#define C_F_BYELLOW 14
#define C_F_BBLUE 9
#define C_F_BMAGENTA 13
#define C_F_BCYAN 11
#define C_F_BWHITE 15
#else
#define utf8() \
{}
#define C_B_BLACK 0
#define C_B_RED 4
#define C_B_GREEN 2
#define C_B_YELLOW 6
#define C_B_BLUE 1
#define C_B_MAGENTA 5
#define C_B_CYAN 3
#define C_B_WHITE 7
#define C_B_BBLACK 8
#define C_B_BRED 12
#define C_B_BGREEN 10
#define C_B_BYELLOW 14
#define C_B_BBLUE 9
#define C_B_BMAGENTA 13
#define C_B_BCYAN 11
#define C_B_BWHITE 15
#define C_F_BLACK 0
#define C_F_RED 4
#define C_F_GREEN 2
#define C_F_YELLOW 6
#define C_F_BLUE 1
#define C_F_MAGENTA 5
#define C_F_CYAN 3
#define C_F_WHITE 7
#define C_F_BBLACK 8
#define C_F_BRED 12
#define C_F_BGREEN 10
#define C_F_BYELLOW 14
#define C_F_BBLUE 9
#define C_F_BMAGENTA 13
#define C_F_BCYAN 11
#define C_F_BWHITE 15
#endif
#define KEY_UP 1
#define KEY_LEFT 2
#define KEY_DOWN 3
#define KEY_RIGHT 4
#define KEY_ENTER 5
void setColor(short f, short b);
void setCursorPos(int x, int y);
int waitForArrowOrEnter();
typedef struct {
int width, height;
} WINSIZE;
WINSIZE getWinSize();
void printDialog(char* texts[], int len, int x, int y, int width, int fC, int bC, int lastInput, int firstMenu);
int launchMenu(char* texts[], int len, int x, int y, int width, int fC, int bC, int firstMenu, char selector, int textStartIndex);
int launchDialog(char* texts[], int len, int x, int y, int width, int fC, int bC, int firstMenu, int selectionfC, int selectionbC, int dialogStartIndex);
int calculateMinWidth(char* texts[], int len);
#endif