-- states/keybindings_menu.lua — the rebinding screen. -- -- Two panels side by side, with focus in exactly one of them: -- left -- the command list ("Menu – accept") -- right -- the keys currently bound to it, plus an "Add a new key" row -- -- `currentlyActiveWindow` says which panel has focus, and both panels have their -- own selection index. Announcing the wrong panel's row would be actively -- misleading here, since the two lists are unrelated. -- -- NOTE: this state is in hotkeys.lua's textEntryStates, so our own hotkeys stay -- out of the way while it is capturing raw keys for rebinding. local lastPanel return { read = function(stateTable, menus) local panel = menus.getAnyUpvalue(stateTable, "currentlyActiveWindow") if type(panel) ~= "string" then return nil, nil end local parts = {} if panel ~= lastPanel then lastPanel = panel parts[#parts + 1] = (panel == "left") and "Commands" or "Keys" end local entry, index, total if panel == "left" then local data = menus.getAnyUpvalue(stateTable, "displayData") index = menus.getAnyUpvalue(stateTable, "currentSelectedOptionLeft") if type(data) == "table" and type(index) == "number" then entry, total = data[index], #data end else local data = menus.getAnyUpvalue(stateTable, "rightPanelDisplayData") index = menus.getAnyUpvalue(stateTable, "currentSelectedOptionRight") if type(data) == "table" and type(index) == "number" then entry, total = data[index], #data end end if not entry then return nil, nil end parts[#parts + 1] = entry.description or entry.scancode or "?" parts[#parts + 1] = index .. " of " .. total return table.concat(parts, ", "), table.concat({panel, tostring(index), tostring(total)}, ":") end, }