summaryrefslogtreecommitdiffstats
path: root/player/lua/defaults.lua
Commit message (Collapse)AuthorAgeFilesLines
* lua: fix guard against division by 0wm42019-12-231-1/+1
| | | | | This was incorrectly converted from the original C code. Change it to what the original code used.
* lua: fix passing non-integers to mp.set_osd_ass()wm42019-12-231-0/+2
| | | | | | | | | | | | | | libass uses integers for PlayResX/Y, so the osd-overlay command also does. Lua (pre-5.3) does not have an integer type, but the command interface makes a difference anyway. If you pass a Lua number with a fractional part to an integer parameter (using mp.command_native()), it will result in an error and complain about incompatible types. I think that's fine, but since this behavior extends to mp.set_osd_ass(), this is a compatibility problem. Fix this by explicitly coercing the resolution parameters to integer numbers.
* client API, lua: add new API for setting OSD overlayswm42019-12-231-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | Lua scripting has an undocumented mp.set_osd_ass() function, which is used by osc.lua and console.lua. Apparently, 3rd party scripts also use this. It's probably time to make this a public API. The Lua implementation just bypassed the libmpv API. To make it usable by any type of client, turn it into a command, "osd-overlay". There's already a "overlay-add". Ignore it (although the manpage admits guiltiness). I don't really want to deal with that old command. Its main problem is that it uses global IDs, while I'd like to avoid that scripts mess with each others overlays (whether that is accidentally or intentionally). Maybe "overlay-add" can eventually be merged into "osd-overlay", but I'm too lazy to do that now. Scripting now uses the commands. There is a helper to manage OSD overlays. The helper is very "thin"; I only want to force script authors to use the ID allocation, which may help with putting multiple scripts into a single .lua file without causing conflicts (basically, avoiding singletons within a script's environment). The old set_osd_ass() is emulated with the new API. The JS scripting wrapper also provides a set_osd_ass() function, which calls internal mpv API. Comment that part (to keep it compiling), but I'm leaving it to @avih to finish the change.
* lua: batch-update key bindingswm42019-12-231-3/+11
| | | | | | | | | | | | | | Lua scripting implements key bindings by defining an input section with all the bindings in it. Every add_key_binding() call ran a mpv command to update this section. This caused a lot of spam at debug log levels. Reduce the spam and more it efficient by batching updates into a single mpv command when the script becomes inactive. This is pretty simple, because there's already the concept of idle handlers. This requires that the script actually goes to sleep, which might not happen in various extremely bogus corner cases, such as polling the mpv message queue with active waiting. Just don't do that.
* command, lua: add a way to share data between scriptswm42019-12-181-0/+24
| | | | | | | | | Very primitive and dumb, but fulfils its purpose for the next commits. I chose this specific implementation because it has the lowest footprint in command.c, without resorting to crazy hacks such as sending messages between scripts (which would be hard to coordinate especially on startup).
* lua: make later key bindings always have higher prioritywm42019-12-071-2/+13
| | | | | | | | | | | | | | | | | | | Later calls to mp.add_key_binding() should take priority over previous calls with the same key. Until now, the order was random (due to using table pairs() iteration order). Do this by simply sorting by a counter that is never reset. Since input.c also gives later bindings priority, this works out. Calling mp.remove_key_binding() on a newer binding makes an older still existing binding with the same key active again. New bindings override older ones, but do not overwrite them. I think these are good semantics for most use cases. (Note that the Lua code cannot determine whether two bindings use the same key. Keys are strings, and two different strings could refer to the same key. The code does not have access to input.c's key name normalization, so it cannot compare them.)
* lua: unbreak mp.add_key_binding(key, fn)Avi Halachmi (:avih)2019-11-301-1/+1
| | | | | | | Commit 311cc5b6 added the ability use flags while omitting name, but broke the case where both name and flags are omitted. Now omitting either name or flags or both works as documented.
* lua: make add_key_binding() rotate optional arguments correctlywm42019-11-231-1/+5
| | | | | | | | add_key_binding() makes the name argument optional (in weird Lua fashion), which did not work if there were additional arguments. So there is no way to avoid specifying a name while passing a rp argument. Fix this, declare this way of skipping the argument as deprecated, and allow passing name=nil as the preferred way to skip the name argument.
* input: add text produced by key to script key eventswm42019-11-221-3/+7
| | | | | | | Particularly for "any_unicode" mappings, so they don't have to special-case keys like '#' and ' ', which are normally mapped to symbolic names for input.conf reasons. (Though admittedly, this is a pretty minor thing, since API users could map these manually.)
* lua: complex key binding: use key_name like the docs sayAvi Halachmi (:avih)2019-11-201-1/+1
|
* lua: report key name for "complex" key bindingswm42019-11-191-4/+5
| | | | This might make certain use cases less of a mess.
* lua: actually unobserve properties in mp.unobserve_property()wm42019-10-241-0/+1
| | | | | | | | | Not doing this looked like a memory leak. This looks like an oversight in the commit that added it: a94020e25bc5f, possible brain damage? Fixes: #6823
* Merge branch 'master' into pr6360Jan Ekström2019-03-111-6/+3
|\ | | | | | | | | | | Manual changes done: * Merged the interface-changes under the already master'd changes. * Moved the hwdec-related option changes to video/decode/vd_lavc.c.
| * lua: execute idle handlers after timers have been processedOlivier Perret2019-01-161-6/+3
| | | | | | | | | | | | | | Idle handlers used to not be executed when timers were active Now they are executed: * After all expired timers have been executed * After all events have been processed (same as when there are no timers)
* | lua: expose mpv_abort_async_command()wm42018-05-241-3/+17
| | | | | | | | Also somewhat cleans up mp.command_native_async() error handling.
* | lua: reimplement mp.subprocess_detached() by invoking the "run" commandwm42018-05-241-0/+4
| | | | | | | | | | | | | | | | The "run" command is old. I'm not sure why the separate Lua implementation was added. But maybe it as because the "run" command used to be limited to a small number of arguments. This limit has been removed a while ago. In any case, the old implementation is not needed anymore.
* | lua: reimplement mp.subprocess() by invoking the new subprocess commandwm42018-05-241-0/+23
| | | | | | | | | | | | | | We keep mp.subprocess() with roughly the same semantics for compatibility with scripts (including the internal ytdl script). Seems to work with rhe ytdl wrapper. Not tested further.
* | lua: expose async commandswm42018-05-241-0/+21
|/ | | | Might be useful for some.
* client API: add a first class hook API, and deprecate old APIwm42018-03-261-10/+7
| | | | | | | | | | | | | | | As it turns out, there are multiple libmpv users who saw a need to use the hook API. The API is kind of shitty and was never meant to be actually public (it was mostly a hack for the ytdl script). Introduce a proper API and deprecate the old one. The old one will probably continue to work for a few releases, but will be removed eventually. There are some slight changes to the old API, but if a user followed the manual properly, it won't break. Mostly untested. Appears to work with ytdl_hook.
* lua: implement mp_utils.format_bytes_humanizedJulian2017-12-261-0/+10
|
* lua: implement mp.msg.traceNiklas Haas2017-12-151-0/+1
|
* lua: allow unregistration of idle handlersOlivier Perret2017-01-151-0/+10
|
* client API: turn mpv_suspend() and mpv_resume() into stubswm42016-11-221-6/+6
| | | | | | | | | | | As threatened by the API changes document. This commit also removes or stubs equivalent calls in IPC and Lua scripting. The stubs are left to maintain ABI compatibility. The semantics of the API functions have been close enough to doing nothing that this probably won't even break existing API users. Probably.
* lua: add API for registering idle handlerswm42016-09-211-0/+10
| | | | | This is only a functionality the Lua event dispatcher provides, rather than the libmpv client API.
* lua: run timers only after draining the event queuewm42016-09-211-12/+11
| | | | | | Instead of rechecking the timers every time after an event is read, do it only once the event queue is empty. This is probably slightly more efficient, and facilitates the next commit.
* Use - as command-name separator everywhereTimotej Lazar2016-07-141-3/+3
| | | | | | | Old-style commands using _ as separator (e.g. show_progress) were still used in some places, including documentation and configuration files. This commit updates all such instances to the new style (show-progress) so that commands are easier to find in the manual.
* lua: add timer:is_enabled() functionJulian2016-05-141-0/+4
| | | | | Allows to query if some timer is currently running or was stopped/killed.
* lua: don't require key for mp.add_key_binding()wm42016-03-261-3/+4
| | | | | Requested. The intention is that scripts can provide mappable actions for key bindings without setting a default key.
* lua: don't suspend core by default during script executionwm42016-03-181-1/+1
| | | | | | | | | This changes behavior somewhat. The old behavior can be restored by running "mp.use_suspend=true". It was originally introduced for the OSC, but I can't reproduce whatever misbehavior I was seeing. (See mp.suspend()/resume() for explanations what the suspend mechanism does.)
* lua: implement input_enable_section/input_disable_section via commandswm42015-08-061-1/+12
| | | | | | | | | | | | | | | Removes some more internal API calls from the Lua scripting backend. Which is good, because ideally the scripting backend would use libmpv functions only. One awkwardness is that mouse sections are still not supported by the public commands (and probably will never), so flags like allow-hide- cursor make no sense to an outside user. Also, the way flags are passed to the Lua function changes. But that's ok, because they're only undocumented internal functions, and not supposed to be used by script users. osc.lua only does due to historical reasons.
* lua: make mp.input_define_section use the define-section commandwm42015-08-061-0/+7
|
* input: allow - as separator between commands, instead of _wm42015-05-251-5/+5
| | | | | | | | | | Wnile it seems quite logical to me that commands use _ as word separator, while properties use -, I can't really explain the difference, and it tends to confuse users as well. So always prefer - as separator for everything. Using _ still works, and will probably forever. Not doing so would probably create too much chaos and confusion.
* lua: replace getcwd() implementationwm42015-03-241-0/+4
|
* Lua: add unpack shim for Lua 5.2/5.3 compatibility.torque2015-03-061-0/+2
| | | | | | | | | The global unpack function got moved to table.unpack in Lua 5.2, and it's only available as the global if 5.2 is built with compatibility enabled (the default). Lua 5.3 does not build with 5.1 compatibility by default. Fixes #1648.
* options: deprecate 'lua' based options/dirs for 'script'Avi Halachmi (:avih)2014-12-151-1/+1
| | | | | | | | | | | | - --lua and --lua-opts change to --script and --script-opts - 'lua' default script dirs change to 'scripts' - DOCS updated - 'lua-settings' dir was _not_ modified The old lua-based names/dirs still work, but display a warning. Signed-off-by: wm4 <wm4@nowhere>
* lua: don't ignore key press events for script key bindingswm42014-12-101-2/+2
| | | | Meh.
* lua: fully cleanup removed key bindingswm42014-12-031-0/+1
| | | | This is basically cosmetic; it was leaking the old handler functions.
* lua: add a function that formats Lua values as stringswm42014-11-291-16/+21
| | | | | | | | Yep, Lua is so crappy that the stdlib doesn't provide anything like this. Repurposes the undocumented mp.format_table() function and moves it to mp.utils.
* lua: remove redundant callwm42014-11-241-1/+0
|
* lua: always handle key repeat on the script sidewm42014-11-241-4/+5
| | | | | | Simpler, and leaves the decision to repeat or not fully to the script (instead of requiring the user to care about it when remapping a script binding).
* lua, ipc: remove leftoverswm42014-11-241-1/+0
| | | | | | MPV_EVENT_SCRIPT_INPUT_DISPATCH is now unused/deprecated. Also remove a debug-print from defaults.lua.
* input, lua: redo input handlingwm42014-11-231-34/+98
| | | | | Much of it is the same, but now there's the possibility to distinguish key down/up events in the Lua API.
* input: set mouse area by default for all inputwm42014-11-231-1/+1
| | | | | | | | | | Otherwise, mouse button bindings added by mp.add_key_binding() would be ignored. It's possible that this "breaks" some older scripts using undocumented Lua script functions, but it should be safe otherwise. Fixes #1283.
* lua: add a way to add repeatable key bindingswm42014-11-211-3/+5
| | | | For these, autorepeat is enabled.
* lua: add convenience function for hookswm42014-10-211-0/+21
| | | | So the user doesn't have to care about the awkward low-level details.
* lua: allow disabling suspendwm42014-08-141-2/+8
| | | | | I'd like to enable this by default, but unfortunately the OSC seems to have some problems with it.
* client API: change mpv_wait_event() timeout semanticswm42014-06-071-1/+1
| | | | | | | | | Now a negative timeout mean an infinite timeout. This is similar to the poll() system call. Apparently this is more intuitive and less confusing than specifying a "very high" value as timeout if you want to wait forever. For callers that never pass negative timeouts, nothing changes.
* lua: make it easier to integrate with foreign event loopswm42014-04-121-6/+26
| | | | We provide some "official" utility functions for this.
* lua: add helper function for printing a tablewm42014-04-111-0/+49
| | | | | | | | | | Although this is something really basic, Lua's standard library doesn't provide anything like this. Probably because there are too many ways to do it right or wrong. This code tries to be really careful when dealing with mixed arrays/maps, e.g. when a table has integer keys starting from 1, making it look like an array, but then also has other keys.
* lua: add a minor helper functionwm42014-04-101-0/+13
|
* lua: add API for observing property changeswm42014-04-081-0/+26
| | | | | A low level API was added already earlier, but that was merely a binding for the raw C API. Add a "proper" one, and document it.
* lua: give more control over timerswm42014-04-021-9/+30
| | | | | | | | | | | Now they can be paused and resumed. Since pausing and disabling the timer is essentially the same underlying operation, we also just provide one method for it. mp.cancel_timer probably still works, but I'm considering this deprecated, and it's removed from the manpage. (We didn't have a release with this function yet, so no formal deprecation.)
* lua: add mp.unregister_event() functionwm42014-04-011-0/+26
| | | | Someone requested this... I think.
* lua: rename mp.register_script_command() to mp.register_script_message()wm42014-03-171-13/+13
| | | | More consistent naming.
* command, lua: change script_message semanticswm42014-03-171-1/+1
| | | | | | | | Change script_message to broadcast the message to all clients. Add a new script_message_to command, which does what the old script_message command did. This is intended as simplification, although it might lead to chaos too.
* lua: fix add_key_binding()wm42014-03-011-2/+2
| | | | | add_key_binding() didn't work, because it passed a flag that was renamed. add_forced_key_binding() worked, but did the wrong thing.
* lua: fix use of renamed functionwm42014-03-011-3/+3
| | | | Apparently this was overlooked when get_timer was renamed to get_time.
* lua: mark table values returned by get_property_native with their typewm42014-02-261-1/+8
| | | | | | | Lua doesn't distinguish between arrays and maps on the language level; there are just tables. Use metatables to mark these tables with their actual types. In particular, it allows distinguishing empty arrays from empty tables.
* lua: implement mp.get_opt() in Luawm42014-02-261-0/+9
| | | | | | Will be more expensive if used very often, but it's probably ok. Reduce the dependency of lua.c on MPContext a bit further.
* osd: override user bindings for OSC inputwm42014-02-261-2/+2
| | | | | | | | | E.g. binding MOUSE_BTN0 always used the user defined binding. While it is ok that the user can override mouse_move and mouse_leave (for whatever reasons), we want to strictly override the bindings when input is sent to the OSC itself. Regression since 03624a1.
* lua: add a bunch of functions to get/set properties by their native typewm42014-02-241-0/+2
| | | | | | There are some complications because the client API distinguishes between integers and floats, while Lua has only "numbers" (which are usually floats). But I think this should work now.
* lua: fix behavior if no script command handler is registeredwm42014-02-231-1/+3
|
* lua: add mechanism for script provided key bindingswm42014-02-171-1/+77
| | | | | | | | | | | | | 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.)
* lua: remove redundant inline documentationwm42014-02-171-4/+0
| | | | | Nobody will loom at this, and the proper documentation of these functions is in lua.rst.
*