-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTUI.hpp
81 lines (81 loc) · 2.37 KB
/
TUI.hpp
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
#include<windows.h>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
#define MAXLEN 1000
#define FR FOREGROUND_RED
#define FB FOREGROUND_BLUE
#define FG FOREGROUND_GREEN
#define BR BACKGROUND_RED
#define BB BACKGROUND_BLUE
#define BG BACKGROUND_GREEN
void gotoxy(short x, short y) {
COORD coord = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void cls() {
COORD coord = {0, 0};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void setcolor(WORD colors) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors);
}
void draw_rect(int begin_x, int begin_y, int end_x, int end_y, WORD colors/*must be BACKGROUND_XXX*/) {
setcolor(colors);
for (int i = begin_x; i <= end_x; i++) {
for (int j = begin_y; j <= end_y; j++) {
gotoxy(i, j);
putchar(' ');
}
}
return ;
}
//void menushow(){
//
//}
//int menu(int posx,int posy,char head[],char choice[][MAXLEN],int nums) {
// int choose=1;
// printf("%s\n",head);
// for(int i=0; i<nums; i++) {
// if(i==choose) {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_GREEN);
// } else {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
// }
// printf("%s\n",choice[i]);
// }
// while(!KEY_DOWN(VK_RETURN)) {
// if(KEY_DOWN(VK_UP) || KEY_DOWN(87)) {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
// gotoxy(0,0);
// choose=max(choose-1,0);
// printf("%s\n",head);
// for(int i=0; i<nums; i++) {
// if(i==choose) {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_GREEN);
// } else {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
// }
// printf("%s\n",choice[i]);
// }
// Sleep(50);
// }
// if(KEY_DOWN(VK_DOWN)||KEY_DOWN(83)) {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
// gotoxy(0,0);
// choose=min(choose+1,nums-1);
// printf("%s\n",head);
// for(int i=0; i<nums; i++) {
// if(i==choose) {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_GREEN);
// } else {
// setcolor(FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
// }
// printf("%s\n",choice[i]);
// }
// Sleep(50);
// }
// }
// return choose;
//}