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.
Showing the changes to player/lua/console.lua (1 of 2 files). Show all
Unified · Split
| @@ -93,6 +93,7 @@ local history_pos = 1 · 92 unmodified lines | ||
| 93 | 93 | local searching_history = false |
| 94 | 94 | local log_buffers = {[id] = {}} |
| 95 | 95 | local key_bindings = {} |
| 96 | +local dont_bind_up_down = false | |
| 96 | 97 | local global_margins = { t = 0, b = 0 } |
| 97 | 98 | local input_caller |
| 98 | 99 | |
| @@ -1624,10 +1625,12 @@ local function define_key_bindings() · 1525 unmodified lines | ||
| 1624 | 1625 | return |
| 1625 | 1626 | end |
| 1626 | 1627 | 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 | |
| 1631 | 1634 | end |
| 1632 | 1635 | mp.add_forced_key_binding("any_unicode", "_console_text", text_input, |
| 1633 | 1636 | {repeatable = true, complex = true}) |
| @@ -1675,6 +1678,7 @@ set_active = function (active) · 41 unmodified lines | ||
| 1675 | 1678 | line = '' |
| 1676 | 1679 | cursor = 1 |
| 1677 | 1680 | selectable_items = nil |
| 1681 | + dont_bind_up_down = false | |
| 1678 | 1682 | end |
| 1679 | 1683 | collectgarbage() |
| 1680 | 1684 | end |
| @@ -1734,6 +1738,7 @@ mp.register_script_message('get-input', function (script_name, args) · 53 unmodified lines | ||
| 1734 | 1738 | line = args.default_text or '' |
| 1735 | 1739 | cursor = args.cursor_position or line:len() + 1 |
| 1736 | 1740 | id = args.id or script_name .. prompt |
| 1741 | + dont_bind_up_down = args.dont_bind_up_down | |
| 1737 | 1742 | if histories[id] == nil then |
| 1738 | 1743 | histories[id] = {} |
| 1739 | 1744 | log_buffers[id] = {} |