From 06cfdc80a6dff91b3e90c726768c5ebbada6c095 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Mon, 24 Jun 2024 04:22:55 +0200 Subject: [PATCH] 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. --- player/lua/console.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/player/lua/console.lua b/player/lua/console.lua index 50a4f1d5fa..ef57e8d3e3 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -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]