Skip to content

Commit

Permalink
Add uppercase letters for hotkey generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kihau committed Sep 27, 2023
1 parent 2b8c275 commit b7e3c11
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lua/dashboard/theme/hyper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ local function letter_hotkey(config)
end
end

math.randomseed(os.time())

-- Create key table, fill it with unused characters.
local unused_keys = {}
-- a - z
Expand All @@ -215,19 +217,24 @@ local function letter_hotkey(config)
table.insert(unused_keys, key)
end
end
-- TODO: Allow generation of upper case characters?
-- Maybe upper characters could be used only after all lowercase ones are exhausted?
-- A - Z
-- for key = 65, 90 do
-- if not vim.tbl_contains(list, key) then
-- table.insert(unused_keys, key)
-- end
-- end

-- Shuffle the unused_keys table.
math.randomseed(os.time())
shuffle_table(unused_keys)

local unused_uppercase_keys = {}
-- A - Z
for key = 65, 90 do
if not vim.tbl_contains(list, key) then
table.insert(unused_uppercase_keys, key)
end
end

shuffle_table(unused_uppercase_keys)

-- Add shuffled uppercase keys after the lowercase ones
for _, key in pairs(unused_uppercase_keys) do
table.insert(unused_keys, key)
end

local fallback_hotkey = 0

return function()
Expand Down

0 comments on commit b7e3c11

Please sign in to comment.