-extern void init_keybindings(char * path, struct KeyBindingDB * kbd)
-{
- char * f_name = "init_keybindings()";
- FILE * file = try_fopen(path, "r", f_name);
- uint32_t lines;
- uint32_t linemax = textfile_sizes(file, &lines);
- char command[linemax + 1];
- char * cmdptr;
- struct KeyBinding ** loc_last_ptr = &kbd->kbs;
- * loc_last_ptr = 0;
- while (try_fgets(command, linemax + 1, file, f_name))
- {
- if ('\n' == command[0] || 0 == command[0])
- {
- break;
- }
- * loc_last_ptr = try_malloc(sizeof(struct KeyBinding), f_name);
- struct KeyBinding * kb_p = * loc_last_ptr;
- kb_p->next = 0;
- kb_p->key = atoi(command);
- cmdptr = strchr(command, ' ') + 1;
- cmdptr[strlen(cmdptr) - 1] = '\0';
- kb_p->command = get_command(cmdptr);
- loc_last_ptr = & kb_p->next;
- }
- try_fclose(file, f_name);
- kbd->edit = 0;
- kbd->select = 0;
-}
-
-
-
-extern void save_keybindings(char * path, struct KeyBindingDB * kbd)
-{
- char * f_name = "save_keybindings()";
- char path_tmp[strlen(path) + 4 + 1];
- sprintf(path_tmp, "%s_tmp", path);
- FILE * file = try_fopen(path_tmp, "w", f_name);
- uint16_t linemax = 0;
- struct KeyBinding * kb_p = kbd->kbs;
- while (0 != kb_p)
- {
- if (strlen(kb_p->command->dsc_short) > linemax)
- {
- linemax = strlen(kb_p->command->dsc_short);
- }
- kb_p = kb_p->next;
- }
- linemax = linemax + 6; /* + 6 = + 3 digits + whitespace + \n + \0 */
- char line[linemax];
- kb_p = kbd->kbs;
- while (0 != kb_p)
- {
- snprintf(line, linemax, "%d %s\n", kb_p->key, kb_p->command->dsc_short);
- try_fwrite(line, sizeof(char), strlen(line), file, f_name);
- kb_p = kb_p->next;
- }
- try_fclose_unlink_rename(file, path_tmp, path, f_name);
-}
-
-
-
-extern void free_keybindings(struct KeyBinding * kb_start)
-{
- if (0 == kb_start)
- {
- return;
- }
- struct KeyBinding * kb_p = kb_start->next;
- if (0 != kb_p)
- {
- free_keybindings(kb_p);
- }
- free(kb_start);
-}
-
-
-
-extern void mod_selected_keyb(struct KeyBindingDB * kbd)