Browse Source

The VIEW structure contain HOTKEYs

Serj Kalichev 11 years ago
parent
commit
e2dfa10f95
3 changed files with 23 additions and 0 deletions
  1. 2 0
      clish/view.h
  2. 2 0
      clish/view/private.h
  3. 19 0
      clish/view/view.c

+ 2 - 0
clish/view.h

@@ -72,6 +72,8 @@ unsigned clish_view__get_depth(const clish_view_t * instance);
 void clish_view__set_restore(clish_view_t * instance,
 	clish_view_restore_t restore);
 clish_view_restore_t clish_view__get_restore(const clish_view_t * instance);
+int clish_view_insert_hotkey(const clish_view_t *instance, const char *key, const char *cmd);
+const char *clish_view_find_hotkey(const clish_view_t *instance, int code);
 
 #endif				/* _clish_view_h */
 /** @} clish_view */

+ 2 - 0
clish/view/private.h

@@ -3,6 +3,7 @@
  */
 #include "clish/view.h"
 #include "lub/bintree.h"
+#include "clish/hotkey.h"
 
 /*---------------------------------------------------------
  * PRIVATE TYPES
@@ -14,6 +15,7 @@ struct clish_view_s {
 	char *prompt;
 	unsigned int nspacec;
 	clish_nspace_t **nspacev;
+	clish_hotkeyv_t *hotkeys;
 	unsigned int depth;
 	clish_view_restore_t restore;
 };

+ 19 - 0
clish/view/view.c

@@ -56,6 +56,9 @@ static void clish_view_init(clish_view_t * this, const char *name, const char *p
 
 	/* set up the defaults */
 	clish_view__set_prompt(this, prompt);
+
+	/* Initialize hotkey structures */
+	this->hotkeys = clish_hotkeyv_new();
 }
 
 /*--------------------------------------------------------- */
@@ -82,6 +85,10 @@ static void clish_view_fini(clish_view_t * this)
 	for (i = 0; i < this->nspacec; i++) {
 		clish_nspace_delete(this->nspacev[i]);
 	}
+
+	/* Free hotkey structures */
+	clish_hotkeyv_delete(this->hotkeys);
+
 	/* free the namespace vector */
 	free(this->nspacev);
 	this->nspacec = 0;
@@ -384,3 +391,15 @@ clish_view_restore_t clish_view__get_restore(const clish_view_t * this)
 }
 
 /*--------------------------------------------------------- */
+int clish_view_insert_hotkey(const clish_view_t *this, const char *key, const char *cmd)
+{
+	return clish_hotkeyv_insert(this->hotkeys, key, cmd);
+}
+
+/*--------------------------------------------------------- */
+const char *clish_view_find_hotkey(const clish_view_t *this, int code)
+{
+	return clish_hotkeyv_cmd_by_code(this->hotkeys, code);
+}
+
+/*--------------------------------------------------------- */