summaryrefslogtreecommitdiffstats
path: root/input/cmd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-23 01:09:09 +0100
committerwm4 <wm4@nowhere>2019-11-23 01:18:49 +0100
commit2dc6b27ee7715cc7d50944a5bbde0a4d3e97771a (patch)
tree7b345680aee05968ed2f8c850d77ceae127aedf6 /input/cmd.c
parentf379cf0bf89ca369e6cea957ef20e9e6579ec230 (diff)
downloadmpv-2dc6b27ee7715cc7d50944a5bbde0a4d3e97771a.tar.bz2
mpv-2dc6b27ee7715cc7d50944a5bbde0a4d3e97771a.tar.xz
input: export input.conf comments ot input-bindings property
This is supposed to turn input.conf comments into inline documentation. Whether this will be useful depends on whether there'll be a script using this field. This changes a small aspect of input.conf parsing fundamentally: this attempts to strip comments/whitespace from the command string, which will later be used to generate the command when a key binding is executed. This should not have any negative effects, but there could be unknown bugs. (For some reason, every command is parsed when input.conf is parsed, but it still only stores the string for the command. I guess that saves some minor amount of memory.)
Diffstat (limited to 'input/cmd.c')
-rw-r--r--input/cmd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/input/cmd.c b/input/cmd.c
index 093e97dbb4..93baa52f43 100644
--- a/input/cmd.c
+++ b/input/cmd.c
@@ -449,7 +449,6 @@ mp_cmd_t *mp_input_parse_cmd_str(struct mp_log *log, bstr str, const char *loc)
*list = (struct mp_cmd) {
.name = (char *)mp_cmd_list.name,
.def = &mp_cmd_list,
- .original = bstrto0(list, original),
};
talloc_steal(list, cmd);
struct mp_cmd_arg arg = {0};
@@ -469,6 +468,16 @@ mp_cmd_t *mp_input_parse_cmd_str(struct mp_log *log, bstr str, const char *loc)
p_prev = &sub->queue_next;
}
+ cmd->original = bstrto0(cmd, bstr_strip(
+ bstr_splice(original, 0, str.start - original.start)));
+
+ str = bstr_strip(str);
+ if (bstr_eatstart0(&str, "#") && !bstr_startswith0(str, "#")) {
+ str = bstr_strip(str);
+ if (str.len)
+ cmd->desc = bstrto0(cmd, str);
+ }
+
done:
talloc_free(tmp);
return cmd;
@@ -510,6 +519,7 @@ mp_cmd_t *mp_cmd_clone(mp_cmd_t *cmd)
m_option_copy(ret->args[i].type, &ret->args[i].v, &cmd->args[i].v);
}
ret->original = talloc_strdup(ret, cmd->original);
+ ret->desc = talloc_strdup(ret, cmd->desc);
ret->sender = NULL;
ret->key_name = talloc_strdup(ret, ret->key_name);
ret->key_text = talloc_strdup(ret, ret->key_text);