summaryrefslogtreecommitdiffstats
path: root/input/cmd_parse.c
Commit message (Collapse)AuthorAgeFilesLines
* input: rename cmd_parse.c to cmd.cwm42018-05-031-473/+0
| | | | | Done separately from the cmd.h rename to avoid issues with git being bad at tracking mixed content and filename changes.
* input: rename cmd_parse.h to cmd.hwm42018-05-031-1/+1
|
* command: split big command handler switch into separate functionswm42018-05-031-3/+0
| | | | | | | | | | | | | | | | | | | This gets rid of run_command() and its big switch statement, which was an idiotically big function of almost 1000 lines. The switch is replaced with a callback per command, and each command is now implemented in its own function. Command IDs are not needed anymore, so the mp_command_type enum disappears. There should be no functional changes, but since this refactors 64 commands, regressions are possible. The handler() parameter is void*, because in theory the input code is supposed to be independent of the player core code. For example, you should be able to reuse the command parser code for some other part of mpv. In practice, the variable containing command list is defined in the player core anyway, so you could say this doesn't work. But I'm still trying to hold onto this idea, so I went with void*.
* input: remove some explicit uses of command IDswm42018-05-031-9/+9
| | | | | | | | | | The plan is to remove the command ID enum. This will happen by replacing the big switch statement in command.c with dispatching to per-command callbacks. As preparation, remove uses of the command IDs outside of the actual dispatching mechanism. Also remove some instances of checking cmd->def for NULL. We now require this always to be set.
* input: remove legacy command handlingwm42018-05-031-7/+0
| | | | | | | | These are old MPlayer commands that were redundant since 2007 or so. In 2013, mpv explicitly deprecated them (actually removed them, but left this wrapper, which translated them to modern commands). The list was not extended since 2013, and mpv always warned on the terminal when a legacy command was used. So it's time to remove it.
* cmd_parse: minor cosmeticswm42018-01-181-5/+2
|
* ta: introduce talloc_dup() and use it in some placeswm42018-01-181-3/+3
| | | | | | | It was actually already implemented as ta_dup_ptrtype(), but that seems like a clunky name. Also we still use the talloc_ names throughout the source, and I'd rather use an old name instead of a mixing inconsistent naming conventions.
* input: make command argument list a dynamic arraywm42018-01-101-47/+46
| | | | | | | | Replace the static array with dynamic memory allocation. This also requires some code to honor mp_cmd.nargs more strictly. Generally allocates more stuff. Fixes #5375 (although we could also just raise the static limit).
* input: change license to LGPLwm42017-06-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cehoyos adds the step_property command in 7a71da01d, and it could be argued that copyright of this still applies to the later add/cycle commands (a668ae0ff90c4). While I'm not sure if this is really the case, stay conservative for now and mark these commands as GPL-only. Mark the command.c code too, although that is not being relicensed yet. I'm leaving the MP_CMD_* enum items, as they are obviously different. In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an "osd_show_property_text" command (well, the commit message says "based on" that person's code, so it's not clear how much is from him or from albeu, who agreed to LGPL). This was later merged again with the "osd_show_text" command, and then all original code was removed in commit 58cc0f637f, so I claim that no copyright applies anymore. (Though technically the input.conf addition still might be copyrighted, so I'm just dropping it to get rid of the thought.) "kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio). The latter is gone. I would argue that the former is fully rewritten with commits b7052b431c9 and 0f155921b0. But like in the step_property case, I will be overly conservative for now, and mark them as GPL-only, as this is potentially shaky and should be thought through first. (Not bothering with the command define/enum in the header, as it will be unused in LGPL mode anyway.) keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a patch by someone who wasn't asked yet. Before doing something radical, I will wait for a reply.
* command: use scale_units to add/cycle integer propertiesJames Ross-Gowan2017-05-121-1/+2
| | | | | | | | | | | | | | | This adds check_property_scalable, which returns true if the property is backed by a floating-point number. When the add or cycle commands operate on these properties, they can benefit from the fractional scale value in cmd->scale. When the property is not backed by a floating-point number, cmd->scale_units is used instead, so for axis events, the property is only incrmented when the user scrolls one full unit. This solution isn't perfect, because in some cases integer-backed properties could benefit from accurate scrolling. For example, if an axis is bound to "cycle audio 5", the cycle command could be made to change the audio track by one when the user scrolls 1/5th of a unit, though this behaviour would require more changes to the options system.
* input: add "async" flagwm42017-04-011-0/+1
| | | | | | | | | | | Obviously, this has no effect on commands which do not support this explicitly. A later commit will enable this for screenshots. Also add some wording on mpv_command_async(), which has nothing to do with this. Having a more elegant, unified behavior would be nice. But the API function was not created for this - it's merely for running commands _synchronously_ on the core, but without blocking the client API caller (if the API user consistently uses only async functions).
* input: fix parsing multiple input command prefixesPhilip Sequeira2016-04-171-1/+0
|
* input: add key name to script-binding command responsewm42015-12-231-0/+1
| | | | | | | | | | | | | | | | The "script-binding" command is used by the Lua scripting wrapper to register key bindings on the fly. It's also the only way to get fine- grained information about key events (such as separate key up/down events). This information is sent via a "key-binding" message when the state of a key changes. Extend it to send name of the mapped key itself. Previously, it was assumed that the user just uses an unique identifier for the binding's name, so it wasn't needed. With this change, a user can map exactly the same command to multiple keys, which is useful especially with the next commit. Part of #2612.
* command: make "add <property> 0" not change the valuewm42015-09-101-0/+7
| | | | | | | | | | | | | | | The value 0 was treated specially, and effectively forced the increment to 1. Interestingly, passing 0 or no value also does not include the scale (from touchpads etc.), but this is probably an accidental behavior that was never intentionally added. Simplify it and make the default increment 1. 0 now means what it should: the value will not be changed. This is not particularly useful, but on the other hand there is no need for surprising and unintuitive semantics. OARG_CYCLEDIR() failed to apply the default value, because m_option_type_cycle_dir was missing a copy handler - add this too.
* input: allow - as separator between commands, instead of _wm42015-05-251-1/+9
| | | | | | | | | | 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.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* input: fix dangling pointerwm42015-01-251-0/+1
| | | | Removes undefined behavior that showed up as crap when running with -v.
* input: simplifywm42014-11-241-2/+8
|
* input: add a prefix to make any binding act on key repeatwm42014-11-201-1/+2
| | | | | | The fact that it's a generic command prefix that is parsed even when using the client API is a bit unclean (because this flag makes sense for actual key-bindings only), but it's less code this way.
* command: don't require whitespace before ';' or '#'wm42014-10-311-4/+1
| | | | | | | This change is probably too simplistic, but most things appear to work, so I don't care about that now. Fixes #1232.
* command: fix debug outputwm42014-10-241-2/+2
| | | | It was a bit ugly/annoying.
* command: print executed commands with -vwm42014-10-231-0/+21
|
* input: remove some unneeded codewm42014-10-101-59/+25
|
* input: cosmetics: move codewm42014-10-101-68/+69
|
* input: use mpv_node parser for char** command parserswm42014-10-101-43/+27
| | | | Minor simplification, also drops some useless stuff.
* input: add a function to parse mpv_node as commandwm42014-10-101-62/+160
| | | | For future client API enhancements.
* input: fix use after free with legacy commandswm42014-09-081-7/+11
| | | | | | | | To handle legacy commands, string replacement is used; the modified string is returned by parse_cmd_str(), but it also frees all temporary memory, which includes the replaced string. Closes #1075.
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* input: fix off by one error in command parserwm42014-08-071-1/+1
| | | | Should fix #989.
* input: remove pausing command prefixeswm42014-05-111-2/+0
| | | | | | These are now equivalent to combining commands with the "cycle pause" or "set pause" commands, and thus are not needed anymore. They were also obscure and undocumented.
* command: fix loadfile commandwm42014-02-241-2/+3
| | | | | | | | | | | | | | | This was broken by commit bb6b543812a724. Note that the original pull request was fine, but it was broken by my own stupidity when I was "improving" it. The problem is that the new loadfile argument was not considered optional anymore after my changes. The original pull request did handle this by setting .defval to a dummy value, but I removed that part. Fix it again by introducing a flag that designates that the parameter is optional. (I didn't want to add it to m_option.h, because technically, all options are optional, and it's not possible to have non-optional options.)
* command: remove special casing for strings in input commandswm42014-02-231-5/+13
| | | | | | Until now, strings were the only allowed dynamically allocated argument type in input commands. Extend it so that it works for any type. (The string expansion in command.c is of course still string specific.)
* common: simplify and optimize string escape parsingwm42013-12-301-26/+1
| | | | | | | | | | | This code is shared between input.conf parser and option parser. Until now, the performance didn't really matter. But I want to use this code for JSON parsing too, and since JSON will have to be parsed a lot, it should probably try to avoid realloc'ing too much. This commit moves parsing of C-style escaped strings into a common function, and allows using it in a way realloc can be completely avoided, if the already allocated buffer is large enough.
* input: split off some code from input.c to separate fileswm42013-12-261-0/+410
This is mostly just moving code around.