summaryrefslogtreecommitdiffstats
path: root/player/lua
Commit message (Collapse)AuthorAgeFilesLines
* stats.lua: display short decoder name if not generic one is usedKacper Michajłow12 hours1-0/+8
|
* stats.lua: filter input bindings by typing themGuido Cella12 hours1-3/+66
| | | | | | | | | This lets you press / in page 4 of the stats and type a keybinding or part of its command to filter it by using mp.input. This works badly without a VO because both stats.lua and console.lua use show-text and only one can be displayed at a time, but it's still better than not having the search available at all.
* stats.lua: inherit OSD stylesGuido Cella14 hours1-11/+24
| | | | | | | | | | | | | | | Avoid having to configure both the OSD and the stats script opts when you change the OSD options, in particular avoid having to convert colors to BGR. Also document the shadow options. font_size, border_size and shadow offset defaults are kept because the same values look much bigger in the stats than in the corresponding OSD options. osd-back-color is now respected without extra checks until you explicitly set a shadow_color.
* osc: add playlist_media_title optionsunpenghao14 hours1-1/+2
| | | | | | Showing media titles in the playlist is pointless when sources are ill tagged and media titles contain only garbage. Being able to opt for file names at least gives us a choice in such cases.
* player/command: remove codec-info and use track-list directlyKacper Michajłow40 hours1-7/+7
| | | | | | | | Turns out that adding more medatata like HDR10+ and Dolby Vision would produce a lot of duplication and it is better to centralize it around the track-list property. Fixes: e720159f72be2a816db849acb286f36a1ac4622b
* stats.lua: add codec profileKacper Michajłow3 days1-2/+10
| | | | | | May be interesting information for users. Fixes: #13839
* stats.lua: remove unused variablesKacper Michajłow5 days1-4/+0
|
* stats.lua: use '➜' (U+279C) instead '→' (U+2192)Kacper Michajłow5 days1-1/+1
|
* stats.lua: fix scrolling for page 2Christoph Heinrich9 days1-1/+1
| | | | | Scrolling for page 2 was disabled in 777f69bee8aceadcd319edf046535e177ef43d48 but the keys were still bound, so this was clearly a mistake.
* console.lua: complete fixed precision propertiesGuido Cella2024-03-211-1/+1
| | | | | Add support for the syntax introduced by 8708f4dc91 in the completion system.
* osc.lua: escape textGuido Cella2024-03-211-10/+5
| | | | | | | | | | | | | | | | | | | | Escape all messages in osc.lua, because other than the title they weren't being escaped at all. If for example you did mpv foo.mp4 '{\fs50}bar.mp4' and script-message osc-playlist, it would just render the second entry as bar.mp4 in big text. The title was escaped partially, now the escaping is complete because: - It escapes \. Backslashes at the end of the title are escaped instead of being stripped, and \n, \N and \h are now printed verbatim. In particular, "\\n" is no longer converted to space and is printed verbatim instead which is more correct. - Newlines ("\n", not the "\\n" escape sequence) are converted to spaces instead of rendering them and messing up the text positioning within the OSC. - Spaces at the start are preserved. Fixes #11209, fixes #11275.
* command: add escape-assGuido Cella2024-03-212-26/+2
| | | | | | | | | | | | | | | | | This adds a command to escape ASS tags to remove code duplication between sub/osd_libass.c, console.lua, osc.lua, stats.lua and any user script that calls mp.create_osd_overlay(). A command is used instead of scripting functions so that all clients can use this and not just use Lua and JS ones. osd_mangle_ass() also interprets osd-sym-cc and osd-ass-cc/{0,1}, but since they use invalid UTF-8 characters there is no risk of escape-ass users using them by accident, like with any OSD message. Always replacing \n with \\N in mangle_ass() even when it is not called by escape-ass doesn't seem to cause any issue, but I made it conditional anyway to avoid changing how all OSD messages are treated unnecessarily.
* stats.lua: use term-size as terminal output sizeChristoph Heinrich2024-03-211-3/+4
| | | | | | | The terminal output was static in size with no way of automatically adjusting it to the current terminal size. The new term-size property makes truly automatic adjustment possible.
* stats.lua: fix and unify scroll hintChristoph Heinrich2024-03-211-10/+11
| | | | | | | | The scroll hint on page 4 had baked in ass tags, which shouldn't be there in the terminal. Also the scroll hint on page 0 was missing. Refactor scroll hint generation into a function and use that for pages 2, 4 and 0.
* stats.lua: use term_ellipsis for page 4Christoph Heinrich2024-03-211-16/+7
| | | | | Page 4 might as well use the same line shortening function as the other pages instead of rolling it's own.
* stats.lua: truncate long lines for the terminalChristoph Heinrich2024-03-211-30/+101
| | | | | | | | | | | | | | | The terminal is assumed to be 80x24 in size, the new options `term_width_limit` and `term_height_limit` can be used to overwrite that. Lines longer then the terminal width cause problems with scrolling pages and need to be shortened. The algorithm used for shortening can deal with tabs and escape sequences, has rudimentary support for UTF-8 and runs in O(n). avih helped in the creation of the term_ellipsis() function and split() is also from him.
* stats.lua: use scroll function for page 2 and 0Christoph Heinrich2024-03-211-52/+30
| | | | | | | | | | | | | | Pages 2 and 0 had their own scroll implementations, which worked fine for ass, but didn't work well in the terminal. Now they both use the same scroll function as page 4. That scroll function requires each output line to be one entry in the table. Page 0 did not adhere to that new requirement, instead it generated two table entries for a single output line when a graph is shown. To fulfill that requirement the generated graph now gets directly appended to the same table entry that's used for the rest of the line.
* stats.lua: refactor page 4 scrolling into functionChristoph Heinrich2024-03-211-10/+24
| | | | | | | | This scrolling implementation will be used for other pages in future commits. The comment said it takes up 20 lines of the terminal, but in reality it was 22 lines.
* stats.lua: add more information in audio sectionKacper Michajłow2024-03-211-6/+21
| | | | | | | | - current AO - AO device - AO volume - audio delay - output format
* osc: add missing window controls for --title-bar=noKacper Michajłow2024-03-181-1/+7
|
* stats.lua: display video parameters after filteringKacper Michajłow2024-03-091-0/+1
|
* console.lua: fix blurry cursor when --osd-blur is setnanahi2024-02-271-1/+1
| | | | | This is drawn with the same method as the stats.lua graphs so it's also blurry. Fix this by using the "Default" style for cursor drawing.
* stats.lua: fix blurry graphs when --osd-blur is setnanahi2024-02-271-1/+1
| | | | | | | | When --osd-blur is set to a nonzero value, the graphs also become blurry. This is because they are rendered by the osd-overlay command with the "OSD" style which has OSD blur applied, and are treated no differently from texts. Fix this by using the "Default" style for these graphs which uses the default OSD options.
* console.lua: move functions to strip common charactersGuido Cella2024-02-081-34/+34
| | | | | | Move common_prefix_length() and related functions before the first call to common_prefix_length(). It works now because it's global but if we ever make all functions local for consistency it will stop working.
* stats.lua: use deinterlace-active property insteadDudemanguy2024-02-071-1/+1
| | | | | But still read the deinterlacing option to distinguish between yes and auto.
* command: add load-config-fileGuido Cella2024-02-041-10/+18
| | | | | | | | Unlike set include mpv.conf, this works after playback has started. It can be used to auto reload the configuration, e.g. in vim: autocmd BufWritePost ~/.config/mpv/mpv.conf silent !echo load-config-file %:p | socat - /tmp/mpvsocket Partially fixes #6362.
* osc: add osc-windowcontrols_title optionDudemanguy2024-01-221-1/+2
| | | | | This allows the title shown with the windowcontrols to be controlled separately from the normal osc title. Fixes #13295.
* stats.lua: display the current GPU contextnanahi2024-01-201-0/+2
| | | | | | This displays the current GPU context when --vo=gpu or --vo=gpu-next is used, which shows the platform and backend information of the vo which are previously not available.
* console.lua: highlight the selected suggestion in the terminalGuido Cella2024-01-201-3/+10
|
* scripting: don't observe properties with type nilGuido Cella2024-01-202-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | mp.observe_property('foo', nil, ...) calls the handler at least 2 times on each playlist change even when the property doesn't change. This is dangerous because if you haven't read observe_property's documentation in a long time this is easy to forget, and you can end up using it for handlers that are computationally expensive or that cause unintended side effects. Therefore, this commit discourages its use more explicitly in the documentation, and replaces its usages in scripts. For console.lua, observing focused with type nil leads to calling mp.osd_message('') when changing file while playing in the terminal with the console disabled. I don't notice issues from this, but it's safer to avoid it. For playlist and track-list this doesn't really matter since they trigger multiple changes on each new file anyway, but changing it can avoid encouraging people to imitate the code. One usage of none in stats.lua is kept because according to b9084dfd47 it is a hack to replicate the deprecated tick event.
* osc: don't autohide mouse cursor when hovering over windowcontrols titlenanahi2024-01-201-0/+14
| | | | | | | | | | | When the mouse cursor is hovering over the (CSD) windowcontrols title, the osc keeps displaying, but the cursor autohide isn't disabled like other visible regions. Fix this by disabling the cursor autohide in this region. All other existing behaviors of the mouse cursor in this region are unchanged, including triggering main window area input and allowing VO dragging.
* stats.lua: make capitalization consistent across pagesllyyr2024-01-171-11/+11
|
* console.lua: style log lines in the terminalGuido Cella2024-01-142-26/+34
| | | | | | | | | | When running the console in the terminal, style log lines with the same escape sequences as msg.c. mp.input can also specify terminal escape sequences, e.g. a script to select a playlist entry can invert the color of the selection. Also add a missing newline to help's error message.
* scripting: add mp.inputGuido Cella2024-01-133-36/+228
| | | | This lets scripts get textual input from the user using console.lua.
* console.lua: expand ~/ in file completionGuido Cella2024-01-041-0/+10
| | | | | | | Makes Tab expand loadfile ~/ to loadfile /home/$USER/. I used expand-path instead of os.getenv('HOME') to make it work on Windows.
* console.lua: hide the cursor when unfocusedGuido Cella2024-01-011-1/+3
| | | | | | | | | | | This is commonly done to understand whether a window is focused. This explicitly checks if focused is false instead of unavailable to not break the cursor where focused is unimplemented like on --vo=drm. The cursor is taller than the input text so it is made transparent instead of completely removing it so that the log doesn't move up and down while toggling focus. Alternatively, cheight = opts.font_size * 8 can be changed to 7.
* console.lua: don't reinsert completion_append after cyclingGuido Cella2024-01-011-8/+10
| | | | | | | 43ed0a83d0 avoided reinserting the string that is appended after certain completions when it is already after the cursor when inserting the longest common prefix of the suggestions. Do the same when cycling through them.
* console.lua: refactor find_common_prefixGuido Cella2023-12-261-16/+7
| | | | | | | | | | | Reuse common_prefix_length() to make find_common_prefix() shorter and faster by not creating many temporary strings. The decrease in the average time to run find_common_prefix() over 1000 calls I measured is: set \<Tab>: 1e-4s -> 1e-5s set s\Tab>: 1e-5s -> 5e-6s
* osc: allow disabling special mouse wheel behaviorDudemanguy2023-12-211-16/+28
| | | | | | | | When hovering certain elements over the OSC, using the mouse wheel can result in special commands (such as seeking, changing audio tracks, etc.) Not everyone neccessarily wants this feature, so add an option to make it possible to disable all of it. Maybe more fine-tuned control would be more ideal, but probably not worth it. Fixes #13096.
* OSC: fix indentation and stray whitepaceHRXN2023-12-171-2/+2
|
* console.lua: clear the suggestions when you move the cursorGuido Cella2023-12-151-0/+12
| | | | | | | | | | | Clear completion suggestions from functions that move the cursor, so that you can't insert suggestions at the wrong spot by pressing Tab again after moving the cursor, Also clear suggestions from some editing functions that were never updated. It is not actually necessary to clear suggestions from functions that remove text in front of the cursor, but since handle_del() already clears them, let's just clear them everywhere.
* console.lua: complete current-tracks sub-propertiesGuido Cella2023-12-151-6/+8
| | | | | | Also inline option-info's sub-properties so we don't have to define sub-properties at the top of the function for every one we decide to complete.
* console.lua: implement case-insensitive completionGuido Cella2023-12-151-16/+58
| | | | | | This is useful for completing files and more rarely for profiles. It will also be useful to third-party scripts interacting with the console once the API to do it is merged.
* Revert "OSC: Remove merriment"Niklas Haas2023-12-131-0/+21
| | | | | This reverts commit af2635d8c9389504cb0b07a78f3999096d80a1ab, and restores feature parity with VLC.
* OSC: Remove merrimentMia Herkt2023-12-131-21/+0
| | | | | | | | | | | | | I honestly don’t care either way but I also don’t believe this innocent and cute hat is worth repeatedly having people show up on the issue tracker to aggressively virtue signal and then shit-talk the project elsewhere when their “concerns” are ignored and made fun of. For the record, I approve of neither brand of childish nonsense. If your workflow depends on December festivities, feel free to use an alternative OSC implementation. Fixes #13082 and #9548
* console.lua: cycle through completionsGuido Cella2023-12-061-18/+55
|
* console: automatically determine the font_hw_ratioChristoph Heinrich2023-12-061-2/+77
| | | | | | | | | | | A simplified version of the text width estimation code from uosc. An osd_overlay is created with compute_bounds=true for measuring the width of the lower case alphabet at what's estimated to be the largest font size possible without clipping. The lower case alphabet was chosen to get decent results for proportional fonts, even if they aren't officially supported.
* console.lua: simplify the condition to print to the terminalGuido Cella2023-12-061-8/+3
| | | | | This was a simpler fix to not print the console log to the OSD while switching VO.
* player: remove shared-script-properties propertyDudemanguy2023-11-221-24/+0
| | | | | | | | | | | | This property was never encouraged. The manual even stated that "You should avoid using it, unless you absolutely have to." Since we now have user-data which is superior in every single way and replaces this, delete this property. The manual also has threatened people for years with the line "It's a makeshift solution which could go away any time (for example, when a better solution becomes available)." We were nice and deprecated it in 1d00aee8e191c9689a20e67e3d6dfd2af6ad2588 for a while to give script authors some time to update. Let's remove it for good now.
* stats.lua: fix incorrect storage aspect ratio valuenanahi2023-11-141-1/+7
| | | | | | | | | | | The "Resolution" property shows the storage resolution for videos with non-square pixels. Currently, display aspect ratio is shown for both "Resolution" and "Output Resolution" properties which results in a duplicate, and is incorrect for the "Resolution" property. The correct aspect ratio is now shown using the sar and sar-name properties.
* console: fix crash for long suggestion stringsChristoph Heinrich2023-11-111-1/+2
| | | | | | | | | String formatting of Lua crashes with widths greater then 99, so limit the value to that. A nicer solution would be to create our own string padding function that can handle bigger widths, but such long suggestions aren't common enough to be worth the effort.
* stats.lua: disable ASS formatting when printing to terminalKacper Michajłow2023-11-081-1/+1
|
* stats.lua: remove unused variableGuido Cella2023-11-071-3/+0
| | | | 056072bf95 deleted the only use of property_list.
* console.lua: don't print the console log to the OSD when switching VOGuido Cella2023-11-071-1/+8
| | | | Fixes #12735, fixes #12839.
* stats: don't overwrite color and alpha of `osd-back-color`Christoph Heinrich2023-11-071-4/+6
|
* console: don't overwrite color and alpha of `osd-back-color`Christoph Heinrich2023-11-071-2/+3
|
* console: wrap rows at the topChristoph Heinrich2023-11-071-8/+6
| | | | | | | | | | The previous commit was already a big improvement, but it was still somewhat slow on the lua interpreter. By wrapping the table at the top we loose the consistent placement of items while resizing (at least as long as the column count didn't change), but we avoid taking all the off screen items into account. The fewer items fit on screen the faster this becomes.
* console: optimize table generationChristoph Heinrich2023-11-071-20/+32
| | | | | | | | | | | Showing all properties was terribly slow. Instead of starting at one row and increasing the row count until it fits, the column count can be increased until it doesn't fit anymore. That alone already reduces the required iterations, but from the column count an upper and lower bound for the row count can be calculated. For large tables this dramatically reduces the amount of iterations.
* console: enable completions without a prefixChristoph Heinrich2023-11-071-4/+4
| | | | | | This way it is possible to get a list of all options or all properties, instead of having to guess the first letter before any suggestions are shown.
* console.lua: complete raw propertiesGuido Cella2023-11-071-1/+1
|
* console: avoid redundant completion appendageChristoph Heinrich2023-11-071-2/+36
| | | | | | So far completing something like `${some-pro}` with the cursor between `o}` would result in `${some-property}}`. Adding that superfluous `}` can be avoided by checking if it's already in the string after the cursor.
* ytdl_hook: fix mixed thumbnail.preference availabilityChristoph Heinrich2023-11-061-1/+1
|
* ALL: use pl_hdr_metadata and nuke sig_peakKacper Michajłow2023-11-051-5/+0
| | | | | | | | This commit replaces all uses of sig_peak and maps all HDR metadata. Form notable changes mixed usage of maxCLL and max_luma is resolved and not always max_luma is used which makes vo_gpu and vo_gpu_next behave the same way.
* csputils: add pl_hdr_metadata to mp_colorspace and deprecate sig_peakKacper Michajłow2023-11-051-5/+3
| | | | | Note this commit does not change all uses of sig-peak, this is for future refactoring.
* lua: remove a ton of unneeded parenthesesDudemanguy2023-11-025-147/+146
| | | | | | | | | | | For whatever reason, some of the lua code (particularly the osc and ytdl_hook) is full of a bunch of stuff like if (foo), if not (foo == nil), etc. The parenthesis aren't needed in lua and actually just look weird since nobody actually writes lua like this. You can see most of the other conditionals are written normally. So cleanup the style to match when the parenthesis clearly aren't doing anything. Not directly related, but also add some spaces on a few math operations while we're at it.
*