mirror of https://github.com/mpv-player/mpv
console.lua: center selectable items around the default item
This commit is contained in:
parent
3e63c97677
commit
661bd61af8
|
@ -1787,7 +1787,13 @@ mp.register_script_message('get-input', function (script_name, args)
|
||||||
matches = {}
|
matches = {}
|
||||||
selected_match = args.default_item or 1
|
selected_match = args.default_item or 1
|
||||||
default_item = args.default_item
|
default_item = args.default_item
|
||||||
first_match_to_print = 1
|
|
||||||
|
local max_lines = calculate_max_log_lines()
|
||||||
|
first_match_to_print = math.max(1, selected_match - math.floor(max_lines / 2) + 2)
|
||||||
|
if first_match_to_print > #selectable_items - max_lines + 2 then
|
||||||
|
first_match_to_print = math.max(1, #selectable_items - max_lines + 2)
|
||||||
|
end
|
||||||
|
|
||||||
for i, item in ipairs(selectable_items) do
|
for i, item in ipairs(selectable_items) do
|
||||||
matches[i] = { index = i, text = item }
|
matches[i] = { index = i, text = item }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue