Add match_empty option to menubar

This commit is contained in:
Ari Breitkreuz 2020-04-21 17:44:23 +02:00
parent 87e7b84ff5
commit ec5ec642c3
1 changed files with 13 additions and 1 deletions

View File

@ -90,6 +90,10 @@ menubar.cache_entries = true
-- @tfield[opt=true] boolean show_categories
menubar.show_categories = true
--- When false will hide results if the current query is empty
-- @tfield[opt=true] boolean match_empty
menubar.match_empty = true
--- Specifies the geometry of the menubar. This is a table with the keys
-- x, y, width and height. Missing values are replaced via the screen's
-- geometry. However, missing height is replaced by the font size.
@ -310,7 +314,7 @@ local function menulist_update(scr)
end
-- Add the applications according to their name and cmdline
for _, v in ipairs(menubar.menu_entries) do
local add_entry = function(v)
v.focused = false
if not current_category or v.category == current_category then
@ -342,6 +346,14 @@ local function menulist_update(scr)
end
end
-- Add entries if required
if query ~= "" or menubar.match_empty then
for _, v in ipairs(menubar.menu_entries) do
add_entry(v)
end
end
local function compare_counts(a, b)
if a.prio == b.prio then
return a.weight > b.weight