History

stats.lua: scroll keybindings while filtering them

console.lua binds up and down to navigate its history. Add a private flag to mp.input.get to instruct console.lua not to bind up and down, so you can use them to scroll the keybindings page while filtering keybindings. If it is requested, this can be replaced with an argument to input.get to not bind arbitrary keys. Fixes #14966.

Guido Cella committed 2 years ago

Commit be814e31 parent b3f84642 files · +10 −4Browse files

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

Unified · Split

player/lua/console.lua+9−4
@@ -93,6 +93,7 @@ local history_pos = 1 · 92 unmodified lines
9393 local searching_history = false
9494 local log_buffers = {[id] = {}}
9595 local key_bindings = {}
96+local dont_bind_up_down = false
9697 local global_margins = { t = 0, b = 0 }
9798 local input_caller
9899
@@ -1624,10 +1625,12 @@ local function define_key_bindings() · 1525 unmodified lines
16241625 return
16251626 end
16261627 for _, bind in ipairs(get_bindings()) do
1627− -- Generate arbitrary name for removing the bindings later.
1628− local name = "_console_" .. (#key_bindings + 1)
1629− key_bindings[#key_bindings + 1] = name
1630− mp.add_forced_key_binding(bind[1], name, bind[2], {repeatable = true})
1628+ if not (dont_bind_up_down and (bind[1] == 'up' or bind[1] == 'down')) then
1629+ -- Generate arbitrary name for removing the bindings later.
1630+ local name = "_console_" .. (#key_bindings + 1)
1631+ key_bindings[#key_bindings + 1] = name
1632+ mp.add_forced_key_binding(bind[1], name, bind[2], {repeatable = true})
1633+ end
16311634 end
16321635 mp.add_forced_key_binding("any_unicode", "_console_text", text_input,
16331636 {repeatable = true, complex = true})
@@ -1675,6 +1678,7 @@ set_active = function (active) · 41 unmodified lines
16751678 line = ''
16761679 cursor = 1
16771680 selectable_items = nil
1681+ dont_bind_up_down = false
16781682 end
16791683 collectgarbage()
16801684 end
@@ -1734,6 +1738,7 @@ mp.register_script_message('get-input', function (script_name, args) · 53 unmodified lines
17341738 line = args.default_text or ''
17351739 cursor = args.cursor_position or line:len() + 1
17361740 id = args.id or script_name .. prompt
1741+ dont_bind_up_down = args.dont_bind_up_down
17371742 if histories[id] == nil then
17381743 histories[id] = {}
17391744 log_buffers[id] = {}

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