home · contact · privacy
Some variable / struct member renaming to better differentiate between keynames and...
authorChristian Heller <c.heller@plomlompom.de>
Tue, 21 Jan 2014 23:02:21 +0000 (00:02 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 21 Jan 2014 23:02:21 +0000 (00:02 +0100)
src/client/control.c
src/client/draw_wins.c
src/client/keybindings.c
src/client/keybindings.h
src/client/wincontrol.c

index 1ccaf453a5bd9ab8d19300e7840b4dd296b0ce12..f7d6e628ab6b2c360450069f6d4addb83b9087cf 100644 (file)
@@ -6,8 +6,8 @@
 #include <string.h> /* strlen() */
 #include "command_db.h" /* get_command_id(), is_command_id_shortdsc() */
 #include "io.h" /* try_send() */
-#include "keybindings.h" /* struct KeyBindingDB, get_actionname_to_keycode(),
-                         * get_keycode_to_action(), mod_selected_keyb(),
+#include "keybindings.h" /* struct KeyBindingDB, get_command_to_keycode(),
+                          * get_keycode_to_command(), mod_selected_keyb(),
                           * move_keyb_mod_selection()
                           */
 #include "map_window.h" /* for map_scroll(), map_center() */
@@ -107,7 +107,7 @@ static uint8_t try_player_cmd(int action, char * match, char * command,
 
 static uint16_t get_available_keycode_to_action(char * name)
 {
-    uint16_t keycode = get_keycode_to_action(world.kb_global.kbs, name);
+    uint16_t keycode = get_keycode_to_command(world.kb_global.kbs, name);
     if (0 != keycode || 0 == world.wmeta.active)
     {
         return keycode;
@@ -115,15 +115,15 @@ static uint16_t get_available_keycode_to_action(char * name)
     struct WinConf * wc = get_winconf_by_win(world.wmeta.active);
     if (0 == wc->view)
     {
-        keycode = get_keycode_to_action(wc->kb.kbs, name);
+        keycode = get_keycode_to_command(wc->kb.kbs, name);
     }
     else if (1 == wc->view)
     {
-        keycode = get_keycode_to_action(world.kb_wingeom.kbs, name);
+        keycode = get_keycode_to_command(world.kb_wingeom.kbs, name);
     }
     else if (2 == wc->view)
     {
-        keycode = get_keycode_to_action(world.kb_winkeys.kbs, name);
+        keycode = get_keycode_to_command(world.kb_winkeys.kbs, name);
     }
     return keycode;
 }
@@ -168,11 +168,11 @@ static void wrap_mv_kb_mod(char c1, char c2)
 
 extern uint8_t player_control(int key)
 {
-    char * action_name = get_actionname_to_keycode(world.kb_global.kbs, key);
+    char * action_name = get_command_to_keycode(world.kb_global.kbs, key);
     if (NULL == action_name && 0 != world.wmeta.active)
     {
         struct WinConf * wc = get_winconf_by_win(world.wmeta.active);
-        action_name = get_actionname_to_keycode(wc->kb.kbs, key);
+        action_name = get_command_to_keycode(wc->kb.kbs, key);
     }
     if (NULL != action_name)
     {
index 90d6519611a3ef8a7aaecf54c4cabe4ba8c05030..c61576c0370679d80ebafdfbeb08c3a71dfa4064 100644 (file)
@@ -8,7 +8,7 @@
 #include <string.h> /* strlen(), strtok() */
 #include "../common/try_malloc.h" /* for try_malloc() */
 #include "command_db.h" /* for get_command_longdsc */
-#include "keybindings.h" /* struct KeyBinding, get_name_to_keycode() */
+#include "keybindings.h" /* struct KeyBinding, get_keyname_to_keycode() */
 #include "wincontrol.h" /* struct WinConf, get_winconf_by_win() */
 #include "windows.h" /* struct Win */
 #include "world.h" /* global world */
@@ -236,8 +236,8 @@ static char * get_kb_line_and_iterate(struct KeyBinding ** kb_pp)
 {
     char * f_name = "get_kb_line_and_iterate()";
     struct KeyBinding * kb_p = * kb_pp;
-    char * keyname = get_name_to_keycode(kb_p->key);
-    char * cmd_dsc = get_command_longdsc(kb_p->name);
+    char * keyname = get_keyname_to_keycode(kb_p->key);
+    char * cmd_dsc = get_command_longdsc(kb_p->command);
     uint16_t size = 9 + 1 + strlen(cmd_dsc) + 1;
     char * line = try_malloc(size, f_name);
     sprintf(line, "%-9s %s", keyname, cmd_dsc);
index 73fc2c8541a7ea346c2ed8d8b697206e68d470ae..709d5a0d4f43e6ce1d94e21b68956352f516a22d 100644 (file)
@@ -77,13 +77,13 @@ static uint8_t try_keycode(uint16_t keycode_given, char * keyname,
 
 
 
-extern char * get_actionname_to_keycode(struct KeyBinding * kb_p, uint16_t key)
+extern char * get_command_to_keycode(struct KeyBinding * kb_p, uint16_t key)
 {
     while (0 != kb_p)
     {
         if (key == kb_p->key)
         {
-            return kb_p->name;
+            return kb_p->command;
         }
         kb_p = kb_p->next;
     }
@@ -92,11 +92,11 @@ extern char * get_actionname_to_keycode(struct KeyBinding * kb_p, uint16_t key)
 
 
 
-extern uint16_t get_keycode_to_action(struct KeyBinding * kb_p, char * name)
+extern uint16_t get_keycode_to_command(struct KeyBinding * kb_p, char * command)
 {
     while (0 != kb_p)
     {
-        if (0 == strcmp(kb_p->name, name))
+        if (0 == strcmp(kb_p->command, command))
         {
             return kb_p->key;
         }
@@ -107,7 +107,7 @@ extern uint16_t get_keycode_to_action(struct KeyBinding * kb_p, char * name)
 
 
 
-extern char * get_name_to_keycode(uint16_t keycode)
+extern char * get_keyname_to_keycode(uint16_t keycode)
 {
     char * f_name = "get_name_to_keycode()";
     char * keyname = try_malloc(15, f_name);                /* FIXME: Why 15? */
@@ -168,9 +168,9 @@ extern void init_keybindings(char * path, struct KeyBindingDB * kbd)
         kb_p->next = 0;
         kb_p->key = atoi(command);
         cmdptr = strchr(command, ' ') + 1;
-        kb_p->name = try_malloc(strlen(cmdptr), f_name);
-        memcpy(kb_p->name, cmdptr, strlen(cmdptr) - 1);
-        kb_p->name[strlen(cmdptr) - 1] = '\0';
+        kb_p->command = try_malloc(strlen(cmdptr), f_name);
+        memcpy(kb_p->command, cmdptr, strlen(cmdptr) - 1);
+        kb_p->command[strlen(cmdptr) - 1] = '\0';
         loc_last_ptr = & kb_p->next;
     }
     try_fclose(file, f_name);
@@ -190,9 +190,9 @@ extern void save_keybindings(char * path, struct KeyBindingDB * kbd)
     struct KeyBinding * kb_p = kbd->kbs;
     while (0 != kb_p)
     {
-        if (strlen(kb_p->name) > linemax)
+        if (strlen(kb_p->command) > linemax)
         {
-            linemax = strlen(kb_p->name);
+            linemax = strlen(kb_p->command);
         }
         kb_p = kb_p->next;
     }
@@ -201,7 +201,7 @@ extern void save_keybindings(char * path, struct KeyBindingDB * kbd)
     kb_p = kbd->kbs;
     while (0 != kb_p)
     {
-        snprintf(line, linemax, "%d %s\n", kb_p->key, kb_p->name);
+        snprintf(line, linemax, "%d %s\n", kb_p->key, kb_p->command);
         try_fwrite(line, sizeof(char), strlen(line), file, f_name);
         kb_p = kb_p->next;
     }
@@ -221,7 +221,7 @@ extern void free_keybindings(struct KeyBinding * kb_start)
     {
         free_keybindings(kb_p);
     }
-    free(kb_start->name);
+    free(kb_start->command);
     free(kb_start);
 }
 
index 4f04342fe274a9690c4aae8ff5d3a717146740f5..7da33567aeeaeae01186c7d377d3f9cc9eb6271f 100644 (file)
@@ -14,7 +14,7 @@ struct KeyBinding
 {
   struct KeyBinding * next;
   uint16_t key; /* keycode */
-  char * name;  /* name of functionality bound to keycode */
+  char * command; /* name of command / functionality bound to keycode */
 };
 
 struct KeyBindingDB
@@ -26,17 +26,17 @@ struct KeyBindingDB
 
 
 
-/* Return name of action / functionality coupled to keycode; NULL on failure. */
-extern char * get_actionname_to_keycode(struct KeyBinding * kb_p, uint16_t key);
+/* Return name of command / functionality bound to keycode; NULL on failure. */
+extern char * get_command_to_keycode(struct KeyBinding * kb_p, uint16_t key);
 
-/* Return keycode matched by keybinding to command of "name". */
-extern uint16_t get_keycode_to_action(struct KeyBinding * keybindings,
-                                      char * name);
+/* Return keycode bound to "command". */
+extern uint16_t get_keycode_to_command(struct KeyBinding * keybindings,
+                                       char * command);
 
 /* Return human-readable name (of maximum 9 chars) for "keycode" as matched by
  * ncurses.h; if none is found, return "UNKNOWN".
  */
-extern char * get_name_to_keycode(uint16_t keycode);
+extern char * get_keyname_to_keycode(uint16_t keycode);
 
 /* Initialize/save keybindings data from/to file at "path" to/from keybindings
  * data pointer "kbd".
index b272905e50bce5cbdba8e001151daa9cd478b053..eda233b43ab762d3bdba90f6fe6e4bc486731770 100644 (file)
@@ -117,9 +117,9 @@ static void init_winconf_from_file(char id, struct WinConf * winconf)
         kb_p->next = 0;
         kb_p->key = atoi(command);
         cmdptr = strchr(command, ' ') + 1;
-        kb_p->name = try_malloc(strlen(cmdptr), context);
-        memcpy(kb_p->name, cmdptr, strlen(cmdptr) - 1);
-        kb_p->name[strlen(cmdptr) - 1] = '\0';
+        kb_p->command = try_malloc(strlen(cmdptr), context);
+        memcpy(kb_p->command, cmdptr, strlen(cmdptr) - 1);
+        kb_p->command[strlen(cmdptr) - 1] = '\0';
         loc_last_ptr = & kb_p->next;
     }
 
@@ -174,9 +174,9 @@ static void save_win_config(char id)
     struct KeyBinding * kb_p = wc->kb.kbs;
     while (0 != kb_p)
     {
-        if (strlen(kb_p->name) > linemax)
+        if (strlen(kb_p->command) > linemax)
         {
-            linemax = strlen(kb_p->name);
+            linemax = strlen(kb_p->command);
         }
         kb_p = kb_p->next;
     }
@@ -185,7 +185,7 @@ static void save_win_config(char id)
     kb_p = wc->kb.kbs;
     while (0 != kb_p)
     {
-        sprintf(kb_line, "%d %s\n", kb_p->key, kb_p->name);
+        sprintf(kb_line, "%d %s\n", kb_p->key, kb_p->command);
         try_fwrite(kb_line, sizeof(char), strlen(kb_line), file, f_name);
         kb_p = kb_p->next;
     }