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