blob: c81678db41447cb2c6493532076829810eee98cb (
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
|
#include <raylib.h>
#include <stdbool.h>
#include "editor.h"
void input_handle_event(struct ed_buf *eb) {
if (IsKeyPressed(KEY_ENTER)) {
eb_newline(eb);
} else if (IsKeyPressed(KEY_BACKSPACE)) {
eb_backspace(eb);
} else if (IsKeyPressed(KEY_LEFT)) {
eb_set_cur_backward(eb);
} else if (IsKeyPressed(KEY_UP)) {
eb_set_cur_prev_line(eb);
} else if (IsKeyPressed(KEY_RIGHT)) {
eb_set_cur_forward(eb);
} else if (IsKeyPressed(KEY_DOWN)) {
eb_set_cur_next_line(eb);
}
if (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)) {
if (IsKeyPressed(KEY_S))
eb_save_file(eb);
}
{
int c;
while ((c = GetCharPressed())) {
eb_insert(eb, c);
}
}
}
|