1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
--
-- ion/share/ioncore_ext.lua -- Ioncore Lua library
--
-- Copyright (c) Tuomo Valkonen 2004-2007.
--
-- See the included file LICENSE for details.
--
-- This is a slight abuse of the package.loaded variable perhaps, but
-- library-like packages should handle checking if they're loaded instead of
-- confusing the user with require/includer differences.
if package.loaded["ioncore"] then return end
-- Default modifiers
--META="Mod4+"
--ALTMETA=""
-- Maximum number of bytes to read from pipes
ioncore.RESULT_DATA_LIMIT=1024^2
-- Bindings, winprops, hooks, menu database and extra commands
dopath('ioncore_luaext')
dopath('ioncore_bindings')
dopath('ioncore_winprops')
dopath('ioncore_misc')
dopath('ioncore_wd')
dopath('ioncore_menudb')
-- Modifier setup compatibility kludge
local oldindex
-- Historically, the options now called 'META' and 'ALTMETA' were called 'MOD1' and 'MOD2'.
-- The code below makes sure:
-- * the default values for those settings are 'Mod4+' (the 'windows key') and 'Mod4+Shift'
-- * that setting either META/ALTMETA or MOD1/MOD2 will specify the primary and secondary meta keys
-- * that getting either META/ALTMETA or MOD1/MOD2 will return the (default or configured) primary and secondary meta keys
local function getmod(t, s)
if s=="META" then
return rawget(t, "MOD1") or "Mod4+"
elseif s=="MOD1" then
return rawget(t, "META") or "Mod4+"
elseif s=="ALTMETA" then
return rawget(t, "MOD2") or "Mod4+Shift+"
elseif s=="MOD2" then
return rawget(t, "ALTMETA") or "Mod4+Shift+"
elseif oldindex then
return oldindex(t, s)
end
end
local oldmeta, newmeta=getmetatable(_G), {}
if oldmeta then
newmeta=table.copy(oldmeta)
oldindex=oldmeta.__index
end
newmeta.__index=getmod
setmetatable(_G, newmeta)
notioncore = ioncore
-- Export some important functions into global namespace.
export(ioncore,
notioncore,
"submap",
"kpress",
"kpress_wait",
"mpress",
"mclick",
"mdblclick",
"mdrag",
"defbindings",
"defwinprop",
"warn",
"exec",
"TR",
"bdoc",
"defmenu",
"defctxmenu",
"menuentry",
"submenu")
-- Mark ourselves loaded.
package.loaded["ioncore"]=true
local function dummy_gettext_hack()
-- Extra translations for context menus etc. I don't want extra
-- TR calls in the configuration files, or parsing the string
-- parameters to kpress etc. for translations.
TR("Frame")
TR("Screen")
TR("Workspace")
TR("Tiling")
TR("Tiled frame")
TR("Floating frame")
TR("Context menu:")
TR("Main menu:")
end
|