Commit Graph

90 Commits

Author SHA1 Message Date
wm4 32fde273d3 lua: don't require key for mp.add_key_binding()
Requested. The intention is that scripts can provide mappable actions
for key bindings without setting a default key.
2016-03-26 10:44:57 +01:00
torque 769f79bd39 man: lua: fix typo in script-binding example.
This line was added in ae5df9be98, and it appears to have been a typo.
2016-03-19 14:09:24 +01:00
wm4 fe67aa7b18 lua: don't suspend core by default during script execution
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.)
2016-03-18 22:03:04 +01:00
wm4 b5d0195023 manpage: lua: fix command names
Both variants work, but the ones with "-" are preferred now.
2015-12-29 01:36:43 +01:00
Martin Herkt fc9eef3b81
man: fix grammar issues 2015-12-19 09:26:41 +01:00
wm4 03c70a8d81 subprocess, lua: export whether the process was killed by us
We want to distinguish actual errors, and just aborting the program
intentionally.

Also be a bit more careful with handling the wait() exit status: do not
called WEXITSTATUS() without checking WIFEXITED() first.
2015-06-27 21:08:55 +02:00
rrooij a87b18aa5a DOCS/manpage: fix typos
Fix some errors in the man pages by spell checking them. Most of them
were typos.

Signed-off-by: wm4 <wm4@nowhere>
2015-06-17 20:13:34 +02:00
wm4 0d2456ae5f lua: support MPV_END_FILE_REASON_REDIRECT
And also add the missing "unknown" entry to the manpage.
2015-06-11 21:42:09 +02:00
wm4 ce513dedd8 lua: export end-file event fields 2015-06-11 21:42:09 +02:00
wm4 327b091909 lua: fix options submodule
It polluted the global namespace, instead of exporting the function
properly.

For now, keep it compatible by explicitly keeping the bogus export.

Also fix a mistake in the manpage example.
2015-05-29 15:50:09 +02:00
wm4 f9ff4b59a2 manpage: lua: clarify OSD differences between mp.command/mp.commandv
Conflicts:
	player/audio.c
	player/video.c
2015-05-16 12:32:34 +02:00
wm4 daabbe3640 lua: add utils.format_json() function
Requested. Why not.
2015-04-22 20:55:05 +02:00
wm4 26909c1113 manpage: lua: clarify timer usage
This seems to come up often. I guess '.' vs. ':' for Lua calls is
confusing, and this part of the scripting API is the only one which
requires using it.
2015-04-08 21:21:44 +02:00
ChrisK2 e9ff136dd3 DOCS, options: fix example 2015-03-05 19:05:58 +01:00
wm4 fa65d657d2 manpage: remove empty line to fix formatting
The HTML rendering of this page formats the ``timeout`` section
differently, and we suspect it's because of this. (Or in other words:
wtf rst??)
2015-03-02 19:09:51 +01:00
wm4 f8dc5db315 manpage: document hook API
This shouldn't exist and for the most part is meant to be used by the
ytdl Lua script, but let's document it anyway. Since the Lua API handles
all the details, it's considered much more "stable" than the raw API,
which is why the raw API wasn't documented.
2015-02-04 23:04:21 +01:00
wm4 e163284b68 command: add on_unload hook
Fixes #1552.
2015-02-04 23:04:01 +01:00
wm4 db4685ac75 manpage: lua: fix a link 2014-12-26 13:43:46 +01:00
wm4 f71696510c manpage: lua: fixes and improvements
Some things were outdated, or outright wrong.
2014-12-25 19:45:17 +01:00
Avi Halachmi (:avih) 39e04e9294 options: deprecate 'lua' based options/dirs for 'script'
- --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>
2014-12-15 04:39:56 +01:00
wm4 aca6ec1394 manpage: lua: fix example
Oops.
2014-11-29 20:27:47 +01:00
wm4 01a3e43ca9 manpage: minor fixes
Also update the Lua example. The "pause" event was declared deprecated,
so the example should use the newer API.
2014-11-29 19:11:07 +01:00
wm4 3295caca3d lua: add a function that formats Lua values as strings
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.
2014-11-29 00:03:46 +01:00
Alessandro Ghedini 134d2475e6 manpage: lua: fix typo paramater -> parameter 2014-11-26 00:08:36 +01:00
wm4 ae5df9be98 input, lua: redo input handling
Much of it is the same, but now there's the possibility to distinguish
key down/up events in the Lua API.
2014-11-23 15:13:35 +01:00
James Ross-Gowan b2d0484404 manpage: update utils.subprocess() for Windows 2014-11-22 18:15:12 +11:00
wm4 00626817c8 lua: add a way to add repeatable key bindings
For these, autorepeat is enabled.
2014-11-21 00:01:59 +01:00
wm4 f5c2e3d6e2 client API: deprecate some events
Following the discussion in #1253.

The events won't be removed for a while, though. (Or maybe never, unless
we run out of bits for the uint64_t event mask.)

This is not a real change (the events still work, and the alternative
mechanisms were established a few API revisions earlier), but for the
sake of notifying API users, update DOCS/client-api-changes.rst.
2014-11-08 10:19:07 +01:00
wm4 40d6b5ca85 lua: add convenience function for hooks
So the user doesn't have to care about the awkward low-level details.
2014-10-21 00:38:56 +02:00
wm4 5548c75e55 lua: expose JSON parser
The JSON parser was introduced for the IPC protocol, but I guess it's
useful here too.

The motivation for this commit is the same as with 8e4fa5fc (again).
2014-10-19 05:51:37 +02:00
wm4 987146362e lua: add an utility function for starting processes
Because 1) Lua is terrible, and 2) popen() is terrible. Unfortunately,
since Unix is also terrible, this turned out more complicated than I
hoped. As a consequence and to avoid that this code has to be maintained
forever, add a disclaimer that any function in Lua's utils module can
disappear any time. The complexity seems a bit ridiculous, especially
for a feature so far removed from actual video playback, so if it turns
out that we don't really need this function, it will be dropped again.

The motivation for this commit is the same as with 8e4fa5fc.

Note that there is an "#ifndef __GLIBC__". The GNU people are very
special people and thought it'd be convenient to actually declare
"environ", even though the POSIX people, which are also very special
people, state that no header declares this and that the user has to
declare this manually. Since the GNU people overtook the Unix world with
their very clever "embrace, extend, extinguish" strategy, but not 100%,
and trying to build without _GNU_SOURCE is hopeless; but since there
might be Unix environments which support _GNU_SOURCE features partially,
this means that in practice "environ" will be randomly declared or not
declared by system headers. Also, gcc was written by very clever people
too, and prints a warning if an external variable is declared twice (I
didn't check, but I suppose redeclaring is legal C, and not even the gcc
people are clever enough to only warn against a definitely not legal C
construct, although sometimes they do this), ...and since we at mpv hate
compiler warnings, we seek to silence them all. Adding a configure test
just for a warning seems too radical, so we special-case this against
__GLIBC__, which is hopefully not defined on other libcs, especially not
libcs which don't implement all aspects of _GNU_SOURCE, and redefine
"environ" on systems even if the headers define it already (because they
support _GNU_SOURCE - as I mentioned before, the clever GNU people wrote
software THAT portable that other libcs just gave up and implemented
parts of _GNU_SOURCE, although probably not all), which means that
compiling mpv will print a warning about "environ" being redefined, but
at least this won't happen on my system, so all is fine. However, should
someone complain about this warning, I will force whoever complained
about this warning to read this ENTIRE commit message, and if possible,
will also force them to eat a printed-out copy of the GNU Manifesto, and
if that is not enough, maybe this person could even be forced to
convince the very clever POSIX people of not doing crap like this:
having the user to manually declare somewhat central symbols - but I
doubt it's possible, because the POSIX people are too far gone and only
care about maintaining compatibility with old versions of AIX and HP-UX.

Oh, also, this code contains some subtle and obvious issues, but writing
about this is not fun.
2014-10-19 05:51:37 +02:00
wm4 c5c21abf78 lua: add command_native() function
This is the Lua equivalent of mpv_command_node().
2014-10-11 00:33:09 +02:00
Kevin Mitchell d4d37245a6 manpage: improve consistency with new ~/.config/mpv default
Signed-off-by: wm4 <wm4@nowhere>
2014-10-04 01:29:12 +02:00
Otto Modinos cbfb6de667 lua: add mpv/lua directories to the lua path
Signed-off-by: wm4 <wm4@nowhere>
2014-09-28 20:23:38 +02:00
wm4 017b3fa9db lua: synchronously wait until scripts are loaded
This makes the player wait until each script is loaded. Do this to give
the script a chance to setup all its event handlers. It might also be
useful to allow a script to change options that matter for playback.

While waiting for a script to be loaded, the player actually accepts
input. This is needed because the scripts can execute player commands
anyway while they are being "loaded". The player won't react to most
commands though: it can't quit or navigate the playlist in this state.

For deciding whether a script is finally loaded, we use a cheap hack: if
mpv_wait_event() is called, it's considered loaded. Let's hope this is
good enough. I think it's better than introducing explicit API for this.
Although I'm sure this will turn out as too simplistic some time in the
future, the same would probably happen with a more explicit API.
2014-09-06 17:02:47 +02:00
Martin Herkt 27a065182c man: fix a whole bunch of typos 2014-09-01 04:27:13 +02:00
Otto Modinos a910b5c6df lua: expose mp_getcwd through mp.utils 2014-08-31 00:58:27 +02:00
Otto Modinos cc971c06f4 manpage: mention that mp.commandv doesn't expand properties
The little lua snippet at #488 as well as the actual implementation
seems to indicate that not expanding properties is indeed the correct
behavior.  Document that.

Signed-off-by: wm4 <wm4@nowhere>
2014-08-25 22:18:25 +02:00
wm4 ecad4a20de manpage: lua: document timer timeout and oneshot fields
Might be useful for scripts, so document them. (Which means scripts
are allowed to use them, without risking breakage.)
2014-07-29 00:22:21 +02:00
wm4 f5e1756475 DOCS: remove en/ sub-directory
This additional sub-directory doesn't serve any purpose anymore. Get rid
of it.
2014-06-20 23:01:12 +02:00