blob: 2dd60745717a88cdd1938829ac9daa43eadf223a (
plain)
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
|
#include <stdio.h>
#include <string.h>
#include <common/ipc.cpp>
#include <common/socket.cpp>
#include <client/window.cpp>
#define NORMAL_MODE 0
#define INSERT_MODE 1
int main(int argc, char *argv[]) {
Window window;
int mode = NORMAL_MODE;
int quit = 0;
while (!quit) {
window.redraw();
int input = getch();
if (mode == NORMAL_MODE) {
switch (input) {
case '':
quit = 1;
break;
case 'i':
mode = INSERT_MODE;
break;
case 'h':
window.move_left();
break;
case 'l':
window.move_right();
break;
}
} else {
switch (input) {
case '':
mode = NORMAL_MODE;
break;
case KEY_BACKSPACE:
window.delete_element();
break;
default:
window.insert_element(input);
}
}
}
return 0;
}
|