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
368368 return result
369369 end
370370
371+local 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
384+end
385+
371386 local function populate_log_with_matches(max_width)
372387 if not selectable_items or selected_match == 0 then
373388 return
@@ -459,7 +474,7 @@ local function print_to_terminal() · 85 unmodified lines
459474 return
460475 end
461476
462− populate_log_with_matches(mp.get_property_native('term-size/w', 80))
477+ populate_log_with_matches(calculate_max_terminal_width())
463478
464479 local log = ''
465480 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