summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-12-29 23:02:42 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-12-29 23:02:42 -0500
commit642b09558e586d47f172fcfd18c296d400317708 (patch)
tree796666be6c3721a3c70dad66bd94c902b297e8ab /main.c
parent51837743b0f90973bf63582a8f34662e9677629e (diff)
started config file
Diffstat (limited to 'main.c')
-rw-r--r--main.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/main.c b/main.c
index 325c7b2..27b5153 100644
--- a/main.c
+++ b/main.c
@@ -9,6 +9,8 @@ no_warn_end
#include <GL/gl.h>
#include <locale.h>
#include <wctype.h>
+
+#include "command.h"
#include "time.c"
#include "unicode.h"
#include "util.c"
@@ -19,6 +21,23 @@ no_warn_end
#include "arr.c"
#include "buffer.c"
+typedef struct {
+ Command cmd;
+ i64 argument;
+} KeyAction;
+
+#define SCANCODE_COUNT 0x120 // SDL scancodes should be less than this value.
+// a "key combo" is some subset of {control, shift, alt} + some key.
+#define KEY_COMBO_COUNT (SCANCODE_COUNT << 3)
+
+typedef struct {
+ TextBuffer *active_buffer;
+ KeyAction key_actions[KEY_COMBO_COUNT];
+ char error[256];
+} Ted;
+
+#include "command.c"
+
static void die(char const *fmt, ...) {
char buf[256] = {0};
@@ -84,7 +103,7 @@ int main(void) {
Uint32 time_at_last_frame = SDL_GetTicks();
while (!quit) {
- #if DEBUG
+ #if DEBUG&&0
printf("\033[H\033[2J");
#endif
@@ -116,7 +135,8 @@ int main(void) {
}
break;
case SDL_KEYDOWN: {
- switch (event.key.keysym.sym) {
+ SDL_Keycode keycode = event.key.keysym.sym;
+ switch (keycode) {
case SDLK_PAGEUP:
buffer_scroll(buffer, 0, -buffer_display_lines(buffer));
break;
@@ -306,7 +326,7 @@ int main(void) {
#if DEBUG
//buffer_print_debug(buffer);
buffer_check_valid(buffer);
- buffer_print_undo_history(buffer);
+ //buffer_print_undo_history(buffer);
#endif
SDL_GL_SwapWindow(window);