Fix various instances of global variables
The modules awful.menu and awful.util were placing variables in the global environment which is a bad thing. Fix this by adding the right module name prefixes to these variables. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
e24c09e828
commit
4c094a279d
|
@ -56,7 +56,7 @@ end
|
||||||
-- key to up action. This is common to all created menu.
|
-- key to up action. This is common to all created menu.
|
||||||
-- @class table
|
-- @class table
|
||||||
-- @name menu_keys
|
-- @name menu_keys
|
||||||
menu_keys = { up = { "Up" },
|
menu.menu_keys = { up = { "Up" },
|
||||||
down = { "Down" },
|
down = { "Down" },
|
||||||
back = { "Left" },
|
back = { "Left" },
|
||||||
exec = { "Return" },
|
exec = { "Return" },
|
||||||
|
@ -196,19 +196,19 @@ local function grabber(_menu, mod, key, event)
|
||||||
if event ~= "press" then return end
|
if event ~= "press" then return end
|
||||||
|
|
||||||
local sel = _menu.sel or 0
|
local sel = _menu.sel or 0
|
||||||
if util.table.hasitem(menu_keys.up, key) then
|
if util.table.hasitem(menu.menu_keys.up, key) then
|
||||||
local sel_new = sel-1 < 1 and #_menu.items or sel-1
|
local sel_new = sel-1 < 1 and #_menu.items or sel-1
|
||||||
_menu:item_enter(sel_new)
|
_menu:item_enter(sel_new)
|
||||||
elseif util.table.hasitem(menu_keys.down, key) then
|
elseif util.table.hasitem(menu.menu_keys.down, key) then
|
||||||
local sel_new = sel+1 > #_menu.items and 1 or sel+1
|
local sel_new = sel+1 > #_menu.items and 1 or sel+1
|
||||||
_menu:item_enter(sel_new)
|
_menu:item_enter(sel_new)
|
||||||
elseif sel > 0 and util.table.hasitem(menu_keys.enter, key) then
|
elseif sel > 0 and util.table.hasitem(menu.menu_keys.enter, key) then
|
||||||
_menu:exec(sel)
|
_menu:exec(sel)
|
||||||
elseif sel > 0 and util.table.hasitem(menu_keys.exec, key) then
|
elseif sel > 0 and util.table.hasitem(menu.menu_keys.exec, key) then
|
||||||
_menu:exec(sel, { exec = true })
|
_menu:exec(sel, { exec = true })
|
||||||
elseif util.table.hasitem(menu_keys.back, key) then
|
elseif util.table.hasitem(menu.menu_keys.back, key) then
|
||||||
_menu:hide()
|
_menu:hide()
|
||||||
elseif util.table.hasitem(menu_keys.close, key) then
|
elseif util.table.hasitem(menu.menu_keys.close, key) then
|
||||||
menu.get_root(_menu):hide()
|
menu.get_root(_menu):hide()
|
||||||
else
|
else
|
||||||
check_access_key(_menu, key)
|
check_access_key(_menu, key)
|
||||||
|
|
|
@ -28,7 +28,7 @@ local capi =
|
||||||
local util = {}
|
local util = {}
|
||||||
util.table = {}
|
util.table = {}
|
||||||
|
|
||||||
shell = os.getenv("SHELL") or "/bin/sh"
|
util.shell = os.getenv("SHELL") or "/bin/sh"
|
||||||
|
|
||||||
function util.deprecate(see)
|
function util.deprecate(see)
|
||||||
io.stderr:write("W: awful: function is deprecated")
|
io.stderr:write("W: awful: function is deprecated")
|
||||||
|
@ -84,7 +84,7 @@ end
|
||||||
-- @param screen The screen where to run the command.
|
-- @param screen The screen where to run the command.
|
||||||
function util.spawn_with_shell(cmd, screen)
|
function util.spawn_with_shell(cmd, screen)
|
||||||
if cmd and cmd ~= "" then
|
if cmd and cmd ~= "" then
|
||||||
cmd = shell .. " -c \"" .. cmd .. "\""
|
cmd = util.shell .. " -c \"" .. cmd .. "\""
|
||||||
return capi.awesome.spawn(cmd, false, screen or capi.mouse.screen)
|
return capi.awesome.spawn(cmd, false, screen or capi.mouse.screen)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue