]> git.decadent.org.uk Git - ion3.git/blob - ioncore/ioncore_ext.lua
Imported Upstream version 20090110
[ion3.git] / ioncore / ioncore_ext.lua
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 --
8
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
13
14 -- Default modifiers
15 --MOD1="Mod1+"
16 --MOD2=""
17
18 -- Maximum number of bytes to read from pipes
19 ioncore.RESULT_DATA_LIMIT=1024^2
20
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')
30
31 -- Modifier setup compatibility kludge
32 local oldindex
33
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
47
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)
55
56 -- Export some important functions into global namespace.
57 export(ioncore, 
58        "submap",
59        "submap_enter",
60        "submap_wait",
61        "kpress",
62        "kpress_wait",
63        "mpress",
64        "mclick",
65        "mdblclick",
66        "mdrag",
67        "defbindings",
68        "defwinprop",
69        "warn",
70        "exec",
71        "TR",
72        "bdoc",
73        "defmenu",
74        "defctxmenu",
75        "menuentry",
76        "submenu")
77
78 -- Mark ourselves loaded.
79 package.loaded["ioncore"]=true
80
81
82
83 local function dummy_gettext_hack()
84     -- Extra translations for context menus etc. I don't want extra
85     -- TR calls in the configuration files, or parsing the string 
86     -- parameters to kpress etc. for translations.
87     TR("Frame")
88     TR("Screen")
89     TR("Workspace")
90     TR("Tiling")
91     TR("Tiled frame")
92     TR("Floating frame")
93     TR("Context menu:")
94     TR("Main menu:")
95 end