forked from TORTRAN/PetaPerang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (63 loc) · 1.31 KB
/
main.cpp
File metadata and controls
74 lines (63 loc) · 1.31 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
#include "clipper.h"
#include "base.h"
static struct termios old, New;
//input without enter
void initTermios(int echo)
{
tcgetattr(0, &old); /* grab old terminal i/o settings */
New = old; /* make new settings same as old settings */
New.c_lflag &= ~ICANON; /* disable buffered i/o */
New.c_lflag &= echo ? ECHO : ~ECHO; /* set echo mode */
tcsetattr(0, TCSANOW, &New); /* use these new terminal i/o settings now */
}
/* Restore old terminal i/o settings */
void resetTermios(void)
{
tcsetattr(0, TCSANOW, &old);
}
/* Read 1 character - echo defines echo mode */
char getch_(int echo)
{
char ch;
initTermios(echo);
ch = getchar();
resetTermios();
return ch;
}
/* Read 1 character without echo */
char getch(void)
{
return getch_(0);
}
/* Read 1 character with echo */
char getche(void)
{
return getch_(1);
}
int main(){
FrameBuffer FB;
Clipper clip;
char input='s';
while(input!='q'){
system("clear");
clip.Draw(FB);
input=getche();
if(input=='i'){
clip.ZoomIn();
}else if(input=='o'){
clip.ZoomOut();
}else if(input=='w'){
clip.MoveUp();
}else if(input=='d'){
clip.MoveRight();
}else if(input=='x'){
clip.MoveDown();
}else if(input=='a'){
clip.MoveLeft();
}
munmap(FB.fbp, FB.screensize);
}
munmap(FB.fbp, FB.screensize);
close(FB.fbfd);
return 0;
}