-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathV-3.cpp
More file actions
89 lines (81 loc) · 2.18 KB
/
V-3.cpp
File metadata and controls
89 lines (81 loc) · 2.18 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
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
#include <iostream>
#include <conio.h>
using namespace std;
class TButton{
public:
char name[50];
int fg,bg;
TButton(int f=96,int b=40){
fg=f;
bg=b;
}
void Name(char *n,int i){
for(int I=0;I<i;I++){
name[I]=n[I];
}
name[i]='\0';
}
};
int function(int no,int opsize,char *p,int x , int y,int line){
TButton A[no];
for(int i=0;i<no;i++){
char a[opsize];
for(int j=0;j<opsize;j++){
a[j]=*(p+50*i+j);
}
A[i].Name(a,opsize);
}
static int count=1;
char M;
while(1){
for(int i=0;i<no;i++){
if(i+1!=count){
printf("\033[0m\033[%d;%dm\033[%d;%dH %s \n",A[i].fg,A[i].bg,i+1+y,x,A[i].name);
}
else{
printf("\033[0m\033[%d;%dm\033[%d;%dH %s \n",106,97,i+1+y,x,A[i].name);
}
}
M=getch();
if(M=='w'||M=='W'){count--;}
else if(M=='s'||M=='S'){count++;}
else if(M=='e'||M=='E'){
if(line==1){
for(int i=0;i<no;i++){
if(i+1!=count){
printf("\033[0m\033[%d;%dm\033[%d;%dH %s \033[%d;%dm \n",A[i].fg,A[i].bg,i+1+y,x,A[i].name,106,97);
}
else{
printf("\033[0m\033[%d;%dm\033[%d;%dH %s \n",106,97,i+1+y,x,A[i].name);
}
}
}
break;
}
if(count<1){
count=no;
}
else if(count>no){
count=1;
}
}
return count;
}
int Option1(){
int options=5;
int optionsize=8;
char *p=new char[50*options];
char a[options][optionsize]={{"OPTION1"},{"OPTION2"},{"OPTION3"},{"OPTION4"},{"OPTION5"}};
for(int i=0;i<options;i++){
int j=0;
for(j=0;j<optionsize;j++){
*(p+i*50+j)=a[i][j];
}
*(p+i*50+j+1)='\0';
}
return function(options,optionsize,p,0,2,0);
}
int main(){
Option1();
return 0;
}