#ifndef CONFIG_H
#define CONFIG_H


#include "app.h"
#include "buffer.h"
#include "keybind.h"


#define AAGK app_add_global_keybind

void config(struct app *app);
void config(struct app *app) {
	AAGK(app, "<left>", keybind_mv_cur_char, DIR_BACKWARD);
	AAGK(app, "<down>", keybind_mv_cur_line, DIR_FORWARD);
	AAGK(app, "<up>", keybind_mv_cur_line, DIR_BACKWARD);
	AAGK(app, "<right>", keybind_mv_cur_char, DIR_FORWARD);

	AAGK(app, "<delete>"   , keybind_delete_char, DIR_FORWARD);
	AAGK(app, "C-d"        , keybind_delete_char, DIR_FORWARD);
	AAGK(app, "<backspace>", keybind_delete_char, DIR_BACKWARD);

	AAGK(app, "C-s", keybind_save_buffer, DIR_NO);
	AAGK(app, "C-k", keybind_delete_to_edg_line, DIR_FORWARD);

	AAGK(app, "A-d", keybind_delete_word, DIR_FORWARD);
	AAGK(app, "C-<backspace>", keybind_delete_word, DIR_BACKWARD);

	AAGK(app, "C-e", keybind_mv_cur_edg_line, DIR_FORWARD);
	AAGK(app, "C-a", keybind_mv_cur_edg_line, DIR_BACKWARD);
	AAGK(app, "A-b", keybind_mv_cur_word, DIR_BACKWARD);
	AAGK(app, "A-f", keybind_mv_cur_word, DIR_FORWARD);

	AAGK(app, "C-s", keybind_save_buffer, DIR_NO);


	char *k = calloc(sizeof(char), 2);
	for ( char c = 32; c < 127; ++c) {
		k[0] = c;
		AAGK(app, k, keybind_insert_last_pressed_key, DIR_NO);
	}
	/* app_add_global_keybind(app, "C-s", keybind_save_buffer, DIR_NO); */
	/* app_add_mode_keybing(app, BUFFER_MODE_TEXT, "<delete>", */
	/* 		     keybing_delete_char, DIR_FORWARD); */
	/* app_add_mode_keybing(app, BUFFER_MODE_TEXT, "<return>", */
	/* 		     keybing_insert_newline, 0); */
	/* printf("config\n"); */
	/* exit(1); */
}

#undef AAGK



/* #define KEYBINDS_MAX_SIZE 1048 */
/* #define KMS KEYBINDS_MAX_SIZE */
/* static struct keybinds keybinds[KMS] = { */
/* 	[SDLK_PERIOD % KMS] = { */
/* 		.size = 1, */
/* 		.binds = { */
/* 			{KMOD_ALT | KMOD_SHIFT, keybind_mv_cur_end_buffer, */
/* 			 {.dir = DIR_FORWARD}} */
/* 		} */
/* 	}, */
/* 	[SDLK_COMMA % KMS] = { */
/* 		.size = 1, */
/* 		.binds = { */
/* 			{KMOD_ALT | KMOD_SHIFT, keybind_mv_cur_end_buffer, */
/* 			 {.dir = DIR_BACKWARD}} */
/* 		} */
/* 	}, */
/* }; */


/* #undef KMS */

#endif
