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
+1
View File
@@ -266,6 +266,7 @@ extern char extcmd_initiator(void);
extern int doextcmd(void); extern int doextcmd(void);
extern struct ext_func_tab *extcmds_getentry(int); extern struct ext_func_tab *extcmds_getentry(int);
extern int count_bind_keys(void); extern int count_bind_keys(void);
extern void get_changed_key_binds(strbuf_t *);
extern void handler_rebind_keys(void); extern void handler_rebind_keys(void);
extern int extcmds_match(const char *, int, int **); extern int extcmds_match(const char *, int, int **);
extern const char *key2extcmddesc(uchar); extern const char *key2extcmddesc(uchar);
+17 -9
View File
@@ -2842,27 +2842,35 @@ count_bind_keys(void)
return nbinds; return nbinds;
} }
static void /* show changed key bindings in text, or if sbuf is non-null, append to it */
display_changed_key_binds(void) void
get_changed_key_binds(strbuf_t *sbuf)
{ {
winid win; winid win;
int i; int i;
char buf[BUFSZ]; char buf[BUFSZ];
char buf2[QBUFSZ]; char buf2[QBUFSZ];
win = create_nhwindow(NHW_TEXT); if (!sbuf)
win = create_nhwindow(NHW_TEXT);
for (i = 0; i < extcmdlist_length; i++) { for (i = 0; i < extcmdlist_length; i++) {
struct ext_func_tab *ec = &extcmdlist[i]; struct ext_func_tab *ec = &extcmdlist[i];
if (ec->key && g.Cmd.commands[ec->key] if (ec->key && g.Cmd.commands[ec->key]
&& g.Cmd.commands[ec->key] != ec) { && g.Cmd.commands[ec->key] != ec) {
Sprintf(buf, "BIND=%s:%s", key2txt(ec->key, buf2), Sprintf(buf, "BIND=%s:%s%s", key2txt(ec->key, buf2),
g.Cmd.commands[ec->key]->ef_txt); g.Cmd.commands[ec->key]->ef_txt,
putstr(win, 0, buf); sbuf ? "\n" : "");
if (sbuf)
strbuf_append(sbuf, buf);
else
putstr(win, 0, buf);
} }
} }
display_nhwindow(win, TRUE); if (!sbuf) {
destroy_nhwindow(win); display_nhwindow(win, TRUE);
destroy_nhwindow(win);
}
} }
/* interactive key binding */ /* interactive key binding */
@@ -3004,7 +3012,7 @@ redo_rebind:
if (i == 1 || i == 2) { if (i == 1 || i == 2) {
handler_rebind_keys_add((i == 1)); handler_rebind_keys_add((i == 1));
} else if (i == 3) { } else if (i == 3) {
display_changed_key_binds(); get_changed_key_binds(NULL);
} }
goto redo_rebind; goto redo_rebind;
} }
+1 -1
View File
@@ -8895,7 +8895,7 @@ all_options_strbuf(strbuf_t *sbuf)
} }
} }
/* TODO: BINDs */ get_changed_key_binds(sbuf);
savedsym_strbuf(sbuf); savedsym_strbuf(sbuf);
all_options_menucolors(sbuf); all_options_menucolors(sbuf);
all_options_msgtypes(sbuf); all_options_msgtypes(sbuf);