0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 19:42:24 +02:00

console.lua: let libass clip lines in select mode

In select mode and when printing the OSD, use \q2 to let libass clip
lines longer than the OSD. This works around having to leave a large
horizontal space unused due to libass subtracting the left margin from
the max text width even though the ASS event is anchored to the bottom
left. It also fixes truncating wide Unicode characters.
This commit is contained in:
Guido Cella 2024-06-24 04:22:55 +02:00 committed by Kacper Michajłow
parent ad6bca9c31
commit 06cfdc80a6

View File

@ -437,7 +437,8 @@ local function populate_log_with_matches(max_width)
for i = first_match_to_print, last_match_to_print do
log[#log + 1] = {
text = truncate_utf8(matches[i].text, max_width) .. '\n',
text = (max_width and truncate_utf8(matches[i].text, max_width)
or matches[i].text) .. '\n',
style = i == selected_match and styles.selected_suggestion or '',
terminal_style = i == selected_match and terminal_styles.selected_suggestion or '',
}
@ -525,7 +526,8 @@ local function update()
'\\1a&H00&\\3a&H00&\\1c&Heeeeee&\\3c&H111111&' ..
(has_shadow and '\\4a&H99&\\4c&H000000&' or '') ..
'\\fn' .. opts.font .. '\\fs' .. opts.font_size ..
'\\bord' .. opts.border_size .. '\\xshad0\\yshad1\\fsp0\\q1' ..
'\\bord' .. opts.border_size .. '\\xshad0\\yshad1\\fsp0' ..
(selectable_items and '\\q2' or '\\q1') ..
'\\clip(' .. clipping_coordinates .. ')}'
-- Create the cursor glyph as an ASS drawing. ASS will draw the cursor
-- inline with the surrounding text, but it sets the advance to the width
@ -555,7 +557,7 @@ local function update()
local suggestions, rows = format_table(suggestion_buffer, width_max, lines_max)
local suggestion_ass = style .. styles.suggestion .. suggestions
populate_log_with_matches(width_max)
populate_log_with_matches()
local log_ass = ''
local log_buffer = log_buffers[id]