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
93local searching_history = false93local searching_history = false
94local log_buffers = {[id] = {}}94local log_buffers = {[id] = {}}
95local key_bindings = {}95local key_bindings = {}
96local dont_bind_up_down = false
96local global_margins = { t = 0, b = 0 }97local global_margins = { t = 0, b = 0 }
97local input_caller98local input_caller
98 99
@@ -1624,10 +1625,12 @@ local function define_key_bindings() · 1525 unmodified lines
1624 return1625 return
1625 end1626 end
1626 for _, bind in ipairs(get_bindings()) do1627 for _, bind in ipairs(get_bindings()) do
1627 -- Generate arbitrary name for removing the bindings later.1628 if not (dont_bind_up_down and (bind[1] == 'up' or bind[1] == 'down')) then
1628 local name = "_console_" .. (#key_bindings + 1)1629 -- Generate arbitrary name for removing the bindings later.
1629 key_bindings[#key_bindings + 1] = name1630 local name = "_console_" .. (#key_bindings + 1)
1630 mp.add_forced_key_binding(bind[1], name, bind[2], {repeatable = true})1631 key_bindings[#key_bindings + 1] = name
1632 mp.add_forced_key_binding(bind[1], name, bind[2], {repeatable = true})
1633 end
1631 end1634 end
1632 mp.add_forced_key_binding("any_unicode", "_console_text", text_input,1635 mp.add_forced_key_binding("any_unicode", "_console_text", text_input,
1633 {repeatable = true, complex = true})1636 {repeatable = true, complex = true})
@@ -1675,6 +1678,7 @@ set_active = function (active) · 41 unmodified lines
1675 line = ''1678 line = ''
1676 cursor = 11679 cursor = 1
1677 selectable_items = nil1680 selectable_items = nil
1681 dont_bind_up_down = false
1678 end1682 end
1679 collectgarbage()1683 collectgarbage()
1680 end1684 end
@@ -1734,6 +1738,7 @@ mp.register_script_message('get-input', function (script_name, args) · 53 unmodified lines
1734 line = args.default_text or ''1738 line = args.default_text or ''
1735 cursor = args.cursor_position or line:len() + 11739 cursor = args.cursor_position or line:len() + 1
1736 id = args.id or script_name .. prompt1740 id = args.id or script_name .. prompt
1741 dont_bind_up_down = args.dont_bind_up_down
1737 if histories[id] == nil then1742 if histories[id] == nil then
1738 histories[id] = {}1743 histories[id] = {}
1739 log_buffers[id] = {}1744 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