summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-17 02:38:07 +0100
committerwm4 <wm4@nowhere>2014-02-17 02:52:58 +0100
commit24fa69dbfa6c5c7a80456218f2c31179864c4d77 (patch)
tree0312cccc355f78cfa1627155eca77cbc0ae6180a /player/lua.c
parent12b7850f11f524ec158b392d7fceabd4ba193ba3 (diff)
downloadmpv-24fa69dbfa6c5c7a80456218f2c31179864c4d77.tar.bz2
mpv-24fa69dbfa6c5c7a80456218f2c31179864c4d77.tar.xz
lua: add mechanism for script provided key bindings
There was already an undocumented mechanism provided by mp.set_key_bindings and other functions, but this was relatively verbose, and also weird. It was mainly to make the OSC happy (including being efficient and supporting weird corner cases), while the new functions try to be a bit simpler. This also provides a way to let users rebind script-provided commands. (This mechanism is less efficient, because it's O(n^2) for n added key bindings, but it shouldn't matter.)
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/player/lua.c b/player/lua.c
index dbe97cc278..e813d84bce 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -666,7 +666,18 @@ static int script_input_define_section(lua_State *L)
struct MPContext *mpctx = get_mpctx(L);
char *section = (char *)luaL_checkstring(L, 1);
char *contents = (char *)luaL_checkstring(L, 2);
- mp_input_define_section(mpctx->input, section, "<script>", contents, true);
+ char *flags = (char *)luaL_optstring(L, 3, "");
+ bool builtin = true;
+ if (strcmp(flags, "builtin") == 0) {
+ builtin = true;
+ } else if (strcmp(flags, "default") == 0) {
+ builtin = false;
+ } else if (strcmp(flags, "") == 0) {
+ //pass
+ } else {
+ luaL_error(L, "invalid flags: '%*'", flags);
+ }
+ mp_input_define_section(mpctx->input, section, "<script>", contents, builtin);
return 0;
}