Commit Graph

747 Commits

Author SHA1 Message Date
nanahi db6b195f3f stats.lua: add option to disable scale with video size
This adds a new configuration option vidscale, which controls whether
stats display is scaled with video, similar to the option for OSC.lua.
2024-04-18 18:44:53 +02:00
nanahi d283688939 stats.lua: add option to control plot border width
This adds a new configuration option plot_bg_border_width, which
controls the border width of plots.
2024-04-18 18:44:53 +02:00
nanahi 5370923a35 stats.lua: remove redundant style override 2024-04-18 18:44:53 +02:00
Kacper Michajłow dc632e16d2 stats.lua: display short decoder name if not generic one is used 2024-04-18 01:20:32 +02:00
Guido Cella 8a4ecda940 stats.lua: filter input bindings by typing them
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.
2024-04-18 01:17:53 +02:00
Guido Cella 51bd00c33a stats.lua: inherit OSD styles
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.
2024-04-17 23:47:55 +02:00
sunpenghao c70cc5b01d osc: add playlist_media_title option
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.
2024-04-17 23:46:35 +02:00
Kacper Michajłow d23f641bb3 player/command: remove codec-info and use track-list directly
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: e720159f72
2024-04-16 21:58:55 +02:00
Kacper Michajłow ab504514b8 stats.lua: add codec profile
May be interesting information for users.

Fixes: #13839
2024-04-15 19:34:40 +02:00
Kacper Michajłow 7a0c8c4619 stats.lua: remove unused variables 2024-04-13 13:37:12 +02:00
Kacper Michajłow 94fbd3683a stats.lua: use '➜' (U+279C) instead '→' (U+2192) 2024-04-13 11:09:10 +02:00
Christoph Heinrich 58eae25fbf stats.lua: fix scrolling for page 2
Scrolling for page 2 was disabled in 777f69bee8
but the keys were still bound, so this was clearly a mistake.
2024-04-09 17:10:21 +02:00
Guido Cella 46a35e2edc console.lua: complete fixed precision properties
Add support for the syntax introduced by 8708f4dc91 in the completion
system.
2024-03-21 08:54:58 +01:00
Guido Cella c84bb1ce67 osc.lua: escape text
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.
2024-03-21 03:20:14 +01:00
Guido Cella d6610a5b2f command: add escape-ass
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.
2024-03-21 03:20:14 +01:00
Christoph Heinrich 97e16be294 stats.lua: use term-size as terminal output size
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.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 0230a0c25a stats.lua: fix and unify scroll hint
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.
2024-03-21 03:08:52 +01:00
Christoph Heinrich c89b8340d5 stats.lua: use term_ellipsis for page 4
Page 4 might as well use the same line shortening function as the other
pages instead of rolling it's own.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 777f69bee8 stats.lua: truncate long lines for the terminal
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.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 344ac5501d stats.lua: use scroll function for page 2 and 0
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.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 16a480375b stats.lua: refactor page 4 scrolling into function
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.
2024-03-21 03:08:52 +01:00
Kacper Michajłow 2a08440afb stats.lua: add more information in audio section
- current AO
- AO device
- AO volume
- audio delay
- output format
2024-03-21 02:40:00 +01:00
Kacper Michajłow ad093567e8 osc: add missing window controls for --title-bar=no 2024-03-18 02:22:28 +00:00
Kacper Michajłow a56d8ff184 stats.lua: display video parameters after filtering 2024-03-09 05:58:52 +00:00
nanahi 3dcc661de7 console.lua: fix blurry cursor when --osd-blur is set
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.
2024-02-27 08:36:56 +01:00
nanahi f4af7b683e stats.lua: fix blurry graphs when --osd-blur is set
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.
2024-02-27 08:36:56 +01:00
Guido Cella 36153d1a4a console.lua: move functions to strip common characters
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.
2024-02-08 18:18:33 +01:00
Dudemanguy fd2c5ee21d stats.lua: use deinterlace-active property instead
But still read the deinterlacing option to distinguish between yes and
auto.
2024-02-07 14:50:09 +00:00
Guido Cella e2284fba18 command: add load-config-file
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.
2024-02-04 15:12:02 +00:00
Dudemanguy 6ae5ff26b0 osc: add osc-windowcontrols_title option
This allows the title shown with the windowcontrols to be controlled
separately from the normal osc title. Fixes #13295.
2024-01-22 14:41:36 +00:00
nanahi 2cb1485492 stats.lua: display the current GPU context
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.
2024-01-20 17:12:07 +00:00
Guido Cella 6302a795d2 console.lua: highlight the selected suggestion in the terminal 2024-01-20 16:10:12 +00:00
Guido Cella de0849404b scripting: don't observe properties with type nil
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.
2024-01-20 16:09:34 +00:00
nanahi c209d4f73b osc: don't autohide mouse cursor when hovering over windowcontrols title
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.
2024-01-20 16:09:22 +00:00
llyyr 22e21edbd4 stats.lua: make capitalization consistent across pages 2024-01-17 09:48:06 +01:00
Guido Cella dfecc9f083 console.lua: style log lines in the terminal
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.
2024-01-14 23:26:07 +01:00
Guido Cella 871f7a152a scripting: add mp.input
This lets scripts get textual input from the user using console.lua.
2024-01-13 02:53:08 +00:00
Guido Cella 448cb4d13d console.lua: expand ~/ in file completion
Makes Tab expand loadfile ~/ to loadfile /home/$USER/.

I used expand-path instead of os.getenv('HOME') to make it work on
Windows.
2024-01-04 13:41:15 +00:00
Guido Cella 28b21e4ab7 console.lua: hide the cursor when unfocused
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.
2024-01-01 14:24:00 +01:00
Guido Cella 731378d1bb console.lua: don't reinsert completion_append after cycling
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.
2024-01-01 14:23:40 +01:00
Guido Cella 19a37f625f console.lua: refactor find_common_prefix
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
2023-12-26 20:12:24 +01:00
Dudemanguy 069143252a osc: allow disabling special mouse wheel behavior
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.
2023-12-21 09:13:11 +01:00
HRXN ba547cb098
OSC: fix indentation and stray whitepace 2023-12-17 08:46:44 -05:00
Guido Cella 8ceaec1742 console.lua: clear the suggestions when you move the cursor
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.
2023-12-15 15:45:11 +00:00
Guido Cella 86c8ef5c1f console.lua: complete current-tracks sub-properties
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.
2023-12-15 15:45:00 +00:00
Guido Cella b09deda37a console.lua: implement case-insensitive completion
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.
2023-12-15 15:44:48 +00:00
Niklas Haas b690531f30 Revert "OSC: Remove merriment"
This reverts commit af2635d8c9, and
restores feature parity with VLC.
2023-12-13 19:29:39 +01:00
Mia Herkt af2635d8c9
OSC: Remove merriment
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
2023-12-13 18:06:22 +01:00
Guido Cella f886eb5678 console.lua: cycle through completions 2023-12-06 19:06:58 +00:00
Christoph Heinrich c16f868dd7 console: automatically determine the font_hw_ratio
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.
2023-12-06 19:06:41 +00:00