History

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.

Guido Cella committed 2 years ago

Commit 06cfdc81 parent ad6bca91 file · +5 −3Browse files

Unified · Split

player/lua/console.lua+5−3
@@ -437,7 +437,8 @@ local function populate_log_with_matches(max_width) · 436 unmodified lines
437437
438438 for i = first_match_to_print, last_match_to_print do
439439 log[#log + 1] = {
440− text = truncate_utf8(matches[i].text, max_width) .. '\n',
440+ text = (max_width and truncate_utf8(matches[i].text, max_width)
441+ or matches[i].text) .. '\n',
441442 style = i == selected_match and styles.selected_suggestion or '',
442443 terminal_style = i == selected_match and terminal_styles.selected_suggestion or '',
443444 }
@@ -525,7 +526,8 @@ local function update() · 81 unmodified lines
525526 '\\1a&H00&\\3a&H00&\\1c&Heeeeee&\\3c&H111111&' ..
526527 (has_shadow and '\\4a&H99&\\4c&H000000&' or '') ..
527528 '\\fn' .. opts.font .. '\\fs' .. opts.font_size ..
528− '\\bord' .. opts.border_size .. '\\xshad0\\yshad1\\fsp0\\q1' ..
529+ '\\bord' .. opts.border_size .. '\\xshad0\\yshad1\\fsp0' ..
530+ (selectable_items and '\\q2' or '\\q1') ..
529531 '\\clip(' .. clipping_coordinates .. ')}'
530532 -- Create the cursor glyph as an ASS drawing. ASS will draw the cursor
531533 -- inline with the surrounding text, but it sets the advance to the width
@@ -555,7 +557,7 @@ local function update() · 23 unmodified lines
555557 local suggestions, rows = format_table(suggestion_buffer, width_max, lines_max)
556558 local suggestion_ass = style .. styles.suggestion .. suggestions
557559
558− populate_log_with_matches(width_max)
560+ populate_log_with_matches()
559561
560562 local log_ass = ''
561563 local log_buffer = log_buffers[id]

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t