Explorar el Código

Adding support for delete key in keybind

Vinicius Teshima hace 1 año
padre
commit
1b71823f84
Se han modificado 2 ficheros con 7 adiciones y 36 borrados
  1. 3 0
      src/app.h
  2. 4 36
      src/config.h

+ 3 - 0
src/app.h

@@ -275,6 +275,9 @@ str_to_keycode(struct str str)
 	if ( str_eq_cstr(str, "<right>", 7) ) {
 		return SDLK_RIGHT;
 	}
+	if ( str_eq_cstr(str, "<delete>", 8) ) {
+		return SDLK_DELETE;
+	}
 	return SDLK_UNKNOWN;
 }
 

+ 4 - 36
src/config.h

@@ -16,6 +16,9 @@ void config(struct app *app) {
 	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-s", keybind_save_buffer, DIR_NO);
 	AAGK(app, "C-k", keybind_delete_to_edg_line, DIR_FORWARD);
 
 	AAGK(app, "C-d", keybind_delete_char, DIR_FORWARD);
@@ -28,6 +31,7 @@ void config(struct app *app) {
 
 	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;
@@ -49,42 +53,6 @@ void config(struct app *app) {
 /* #define KEYBINDS_MAX_SIZE 1048 */
 /* #define KMS KEYBINDS_MAX_SIZE */
 /* static struct keybinds keybinds[KMS] = { */
-/* 	[SDLK_LEFT % KMS] = { */
-/* 		.size = 1, */
-/* 		.binds = { */
-/* 			{KMOD_NONE, keybind_mv_cur_char, {.dir = DIR_BACKWARD}} */
-/* 		} */
-/* 	}, */
-/* 	[SDLK_RIGHT % KMS] = { */
-/* 		.size = 1, */
-/* 		.binds = { */
-/* 			{KMOD_NONE, keybind_mv_cur_char, {.dir = DIR_FORWARD}} */
-/* 		} */
-/* 	}, */
-/* 	[SDLK_DELETE % KMS] = { */
-/* 		.size = 1, */
-/* 		.binds = { */
-/* 			{KMOD_NONE, keybind_delete_char, {.dir = DIR_FORWARD}}, */
-/* 		} */
-/* 	}, */
-/* 	[SDLK_UP % KMS] = { */
-/* 		.size = 1, */
-/* 		.binds = { */
-/* 			{KMOD_NONE, keybind_mv_cur_line, {.dir = DIR_BACKWARD}} */
-/* 		} */
-/* 	}, */
-/* 	[SDLK_DOWN % KMS] = { */
-/* 		.size = 1, */
-/* 		.binds = { */
-/* 			{KMOD_NONE, keybind_mv_cur_line, {.dir = DIR_FORWARD}} */
-/* 		} */
-/* 	}, */
-/* 	[SDLK_RETURN % KMS] = { */
-/* 		.size = 1, */
-/* 		.binds = { */
-/* 			{KMOD_NONE, keybind_insert_newline, {.ptr = NULL}} */
-/* 		} */
-/* 	}, */
 /* 	[SDLK_BACKSPACE % KMS] = { */
 /* 		.size = 2, */
 /* 		.binds = { */