-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
46 lines (40 loc) · 879 Bytes
/
main.c
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
#include "common.h"
#include "raw-mode.h"
#include "initialize.h"
#include "render.h"
#include "input.h"
int main(int argc, char** argv)
{
E.drawing_mode = 1;
int option;
while ((option = getopt(argc, argv, ":p:")) != -1)
{
switch(option)
{
case 'p': // 'p' for 'picture'
E.filename = optarg;
E.drawing_mode = 0;
break;
case ':':
fprintf(stderr, "You must provide a file.\n");
exit(0);
break;
}
}
if (E.drawing_mode)
{
enable_raw_mode();
init_editor(argv[1]);
while (1)
{
draw_screen();
get_input();
}
}
else // if not drawing, just print picture
{
init_editor(E.filename);
draw_rows();
}
return 0;
}