From b27c3bf193cb949c2173f39bbeb8a8f785c3d76f Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Wed, 18 Dec 2013 00:08:31 -0500 Subject: Enable read-only access to the current chain of key sequences; core/keys.lua --- core/keys.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core') diff --git a/core/keys.lua b/core/keys.lua index 5f168028..ae986f98 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -172,6 +172,17 @@ M.KEYSYMS = { -- The current key sequence. local keychain = {} +--- +-- The current chain of key sequences. (Read-only.) +-- Use the '#' operator (instead of `ipairs()`) for iteration. +-- @class table +-- @name keychain +M.keychain = setmetatable({}, { + __index = keychain, + __newindex = function() error("'keys.keychain' is read-only") end, + __len = function() return #keychain end +}) + -- Clears the current key sequence. local function clear_key_sequence() -- Clearing a table is faster than re-creating one. -- cgit v1.2.3