stats.lua: use term-size as terminal output size

The terminal output was static in size with no way of automatically
adjusting it to the current terminal size.

The new term-size property makes truly automatic adjustment possible.
This commit is contained in:
Christoph Heinrich 2023-08-31 23:16:30 +02:00 committed by Kacper Michajłow
parent 0c8f3bc73c
commit 97e16be294
1 changed files with 4 additions and 3 deletions

View File

@ -1065,8 +1065,9 @@ end
-- content : table of the content where each entry is one line
-- apply_scroll: scroll the content
local function finalize_page(header, content, apply_scroll)
local term_width = o.term_width_limit or 80
local term_height = o.term_height_limit or 24
local term_size = mp.get_property_native("term-size", {})
local term_width = o.term_width_limit or term_size.w or 80
local term_height = o.term_height_limit or term_size.h or 24
local from, to = 1, #content
if apply_scroll and term_height > 0 then
-- Up to 40 lines for libass because it can put a big performance toll on
@ -1483,7 +1484,7 @@ if o.bindlist ~= "no" then
mp.add_timeout(0, function() -- wait for all other scripts to finish init
o.ass_formatting = false
o.no_ass_indent = " "
o.term_size.w = width
o.term_size = { w = width , h = 0}
io.write(keybinding_info(false, true) .. "\n")
mp.command("quit")
end)