-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathced.c
46 lines (34 loc) · 770 Bytes
/
ced.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 <curses.h>
#include <stdbool.h>
#include <ctype.h>
#include "editor.h"
#define KEY_ESCAPE 27
void init_screen() {
initscr();
raw();
noecho();
}
void init_colors() {
start_color();
use_default_colors();
init_pair(1, COLOR_BLACK, COLOR_WHITE);
}
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: ./interface <filename>\n");
exit(1);
}
int key;
init_screen();
init_colors();
refresh();
Editor *editor = editor_new(argv[1]);
editor_redraw_view(editor);
while ((key = wgetch(editor->view->win)) != KEY_ESCAPE) {
editor_handle_key(editor, key);
editor_redraw_view(editor);
}
endwin();
editor_destroy(editor);
return 0;
}