Parcourir la source

[app.h] Adding map for keymaps

Vinicius Teshima il y a 1 an
Parent
commit
307a158b03
1 fichiers modifiés avec 15 ajouts et 4 suppressions
  1. 15 4
      src/app.h

+ 15 - 4
src/app.h

@@ -30,7 +30,8 @@ struct app_kbd {
 	enum keybind_dir dir;
 };
 
-HT_DEF_STRUCT(struct app_kbd, app_kbd_ht);
+HT_DEF_STRUCT(struct app_kbd, km);
+HT_DEF_STRUCT(struct km, km_ht);
 
 struct app {
 	struct window win;
@@ -49,7 +50,8 @@ struct app {
 	bool show_fps;
 	struct free_glyph_atlas *fga;
 	struct cursor_render *cr;
-	struct app_kbd_ht *ckm;
+	struct km *ckm;
+	struct km_ht km_ht;
 };
 
 #include "free_glyph.h"
@@ -117,8 +119,16 @@ app_create(const char *win_title)
 		.target_fps = 120,
 	};
 
-	HT_CREATE(*app.ckm, 16);
-	app.ckm->hash = ht_hash_nop;
+	HT_CREATE(app.km_ht, 4);
+	app.km_ht.hash = ht_hash_nop;
+
+	struct km t = {0};
+	HT_CREATE(t, 16);
+	t.hash = ht_hash_nop;
+
+	HT_ISET(app.km_ht, 1, t);
+	HT_IGET_PTR(app.km_ht, 1, app.ckm);
+
 	DA_CREATE(app.bufs);
 	DA_APPEND(app.bufs, buffer_create());
 	app.cbuf = &app.bufs.items[0];
@@ -382,6 +392,7 @@ app_add_global_keybind(struct app *app, const char *keybind,
 		return;
 	}
 
+	/* Permit prefix keybind like C-x b */
 	struct str_da words = str_split(kbd_str, ' ');
 	IF_GOTO(words.size != 1, invalid_key);
 	/* for */ {