Save changed key binds to config file

This commit is contained in:
Pasi Kallinen
2022-08-05 13:07:26 +03:00
parent 45613ea771
commit fa1b326e31
3 changed files with 19 additions and 10 deletions

View File

@@ -266,6 +266,7 @@ extern char extcmd_initiator(void);
extern int doextcmd(void);
extern struct ext_func_tab *extcmds_getentry(int);
extern int count_bind_keys(void);
extern void get_changed_key_binds(strbuf_t *);
extern void handler_rebind_keys(void);
extern int extcmds_match(const char *, int, int **);
extern const char *key2extcmddesc(uchar);

View File

@@ -2842,27 +2842,35 @@ count_bind_keys(void)
return nbinds;
}
static void
display_changed_key_binds(void)
/* show changed key bindings in text, or if sbuf is non-null, append to it */
void
get_changed_key_binds(strbuf_t *sbuf)
{
winid win;
int i;
char buf[BUFSZ];
char buf2[QBUFSZ];
win = create_nhwindow(NHW_TEXT);
if (!sbuf)
win = create_nhwindow(NHW_TEXT);
for (i = 0; i < extcmdlist_length; i++) {
struct ext_func_tab *ec = &extcmdlist[i];
if (ec->key && g.Cmd.commands[ec->key]
&& g.Cmd.commands[ec->key] != ec) {
Sprintf(buf, "BIND=%s:%s", key2txt(ec->key, buf2),
g.Cmd.commands[ec->key]->ef_txt);
putstr(win, 0, buf);
Sprintf(buf, "BIND=%s:%s%s", key2txt(ec->key, buf2),
g.Cmd.commands[ec->key]->ef_txt,
sbuf ? "\n" : "");
if (sbuf)
strbuf_append(sbuf, buf);
else
putstr(win, 0, buf);
}
}
display_nhwindow(win, TRUE);
destroy_nhwindow(win);
if (!sbuf) {
display_nhwindow(win, TRUE);
destroy_nhwindow(win);
}
}
/* interactive key binding */
@@ -3004,7 +3012,7 @@ redo_rebind:
if (i == 1 || i == 2) {
handler_rebind_keys_add((i == 1));
} else if (i == 3) {
display_changed_key_binds();
get_changed_key_binds(NULL);
}
goto redo_rebind;
}

View File

@@ -8895,7 +8895,7 @@ all_options_strbuf(strbuf_t *sbuf)
}
}
/* TODO: BINDs */
get_changed_key_binds(sbuf);
savedsym_strbuf(sbuf);
all_options_menucolors(sbuf);
all_options_msgtypes(sbuf);