console.lua: only clip items between UTF-8 characters

Since with the new horizontal scrolling the end of lines can be visible,
ensure not to clip lines in the middle of UTF-8 characters to not show
mojibake, also adding … to show when items are clipped.

Also replace the existing use of ⋯  with …
This commit is contained in:
Guido Cella
2026-01-07 01:09:00 +01:00
committed by Kacper Michajłow
parent a385c0635b
commit 85bf9f4ff4
+3 -1
View File
@@ -1693,7 +1693,9 @@ mp.register_script_message("get-input", function (script_name, args)
end
for i, item in ipairs(args.items) do
selectable_items[i] = item:gsub("[\r\n].*", "⋯"):sub(1, limit)
local last = next_utf8(item, limit) - 1
selectable_items[i] = item:gsub("[\r\n].*", "…"):sub(1, last) ..
(last < #item and "…" or "")
end
calculate_max_item_width()