mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 00:02:13 +00:00
lua: make mp.input_define_section use the define-section command
This commit is contained in:
parent
d1179f9501
commit
9bcc882659
21
player/lua.c
21
player/lua.c
@ -1024,26 +1024,6 @@ static int script_get_time(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
char *flags = (char *)luaL_optstring(L, 3, "");
|
||||
bool builtin = true;
|
||||
if (strcmp(flags, "default") == 0) {
|
||||
builtin = true;
|
||||
} else if (strcmp(flags, "force") == 0) {
|
||||
builtin = false;
|
||||
} else if (strcmp(flags, "") == 0) {
|
||||
//pass
|
||||
} else {
|
||||
luaL_error(L, "invalid flags: '%s'", flags);
|
||||
}
|
||||
mp_input_define_section(mpctx->input, section, "<script>", contents, builtin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int script_input_enable_section(lua_State *L)
|
||||
{
|
||||
struct MPContext *mpctx = get_mpctx(L);
|
||||
@ -1321,7 +1301,6 @@ static const struct fn_entry main_fns[] = {
|
||||
FN_ENTRY(get_screen_margins),
|
||||
FN_ENTRY(get_mouse_pos),
|
||||
FN_ENTRY(get_time),
|
||||
FN_ENTRY(input_define_section),
|
||||
FN_ENTRY(input_enable_section),
|
||||
FN_ENTRY(input_disable_section),
|
||||
FN_ENTRY(input_set_section_mouse_area),
|
||||
|
@ -24,6 +24,13 @@ function mp.get_opt(key, def)
|
||||
return val
|
||||
end
|
||||
|
||||
function mp.input_define_section(section, contents, flags)
|
||||
if flags == nil or flags == "" then
|
||||
flags = "default"
|
||||
end
|
||||
mp.commandv("define-section", section, contents, flags)
|
||||
end
|
||||
|
||||
-- For dispatching script_binding. This is sent as:
|
||||
-- script_message_to $script_name $binding_name $keystate
|
||||
-- The array is indexed by $binding_name, and has functions like this as value:
|
||||
|
Loading…
Reference in New Issue
Block a user