History

console.lua: truncate more characters with --msg-module and --msg-time

Fix the terminal width calculation for the select menu with these options.

Guido Cella committed 2 years ago

Commit 85922061 parent b98d4fd1 file · +16 −1Browse files

Showing the changes to player/lua/console.lua (1 of 1 file). Show all

Unified · Split

player/lua/console.lua+16−1
@@ -368,6 +368,21 @@ local function fuzzy_find(needle, haystacks) · 367 unmodified lines
368 return result368 return result
369end369end
370 370
371local function calculate_max_terminal_width()
372 local max_width = mp.get_property_native('term-size/w', 80)
373
374 -- The longest module name is vo/gpu-next/libplacebo.
375 if mp.get_property_native('msg-module') then
376 max_width = max_width - 24
377 end
378
379 if mp.get_property_native('msg-time') then
380 max_width = max_width - 13
381 end
382
383 return max_width
384end
385
371local function populate_log_with_matches(max_width)386local function populate_log_with_matches(max_width)
372 if not selectable_items or selected_match == 0 then387 if not selectable_items or selected_match == 0 then
373 return388 return
@@ -459,7 +474,7 @@ local function print_to_terminal() · 85 unmodified lines
459 return474 return
460 end475 end
461 476
462 populate_log_with_matches(mp.get_property_native('term-size/w', 80))477 populate_log_with_matches(calculate_max_terminal_width())
463 478
464 local log = ''479 local log = ''
465 for _, log_line in ipairs(log_buffers[id]) do480 for _, log_line in ipairs(log_buffers[id]) do

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