]> git.decadent.org.uk Git - ion3.git/blob - ioncore/ioncore_ext.lua
[svn-upgrade] Integrating new upstream version, ion3 (20070506)
[ion3.git] / ioncore / ioncore_ext.lua
1 --
2 -- ion/share/ioncore_ext.lua -- Ioncore Lua library
3 -- 
4 -- Copyright (c) Tuomo Valkonen 2004-2007.
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
30 -- Modifier setup compatibility kludge
31 local oldindex
32
33 local function getmod(t, s)
34     if s=="META" then
35         return rawget(t, "MOD1") or "Mod1+"
36     elseif s=="MOD1" then
37         return rawget(t, "META") or "Mod1+"
38     elseif s=="ALTMETA" then
39         return rawget(t, "MOD2") or ""
40     elseif s=="MOD2" then
41         return rawget(t, "ALTMETA") or ""
42     elseif oldindex then
43         return oldindex(t, s)
44     end
45 end
46
47 local oldmeta, newmeta=getmetatable(_G), {}
48 if oldmeta then
49     newmeta=table.copy(oldmeta)
50     oldindex=oldmeta.__index
51 end
52 newmeta.__index=getmod
53 setmetatable(_G, newmeta)
54
55 -- Export some important functions into global namespace.
56 export(ioncore, 
57        "submap",
58        "submap_enter",
59        "submap_wait",
60        "kpress",
61        "kpress_wait",
62        "mpress",
63        "mclick",
64        "mdblclick",
65        "mdrag",
66        "defbindings",
67        "defwinprop",
68        "warn",
69        "exec",
70        "TR",
71        "bdoc",
72        "defmenu",
73        "defctxmenu",
74        "menuentry",
75        "submenu")
76
77 -- Mark ourselves loaded.
78 package.loaded["ioncore"]=true
79
80
81
82 local function dummy_gettext_hack()
83     -- Extra translations for context menus etc. I don't want extra
84     -- TR calls in the configuration files, or parsing the string 
85     -- parameters to kpress etc. for translations.
86     TR("Frame")
87     TR("Screen")
88     TR("Workspace")
89     TR("Tiling")
90     TR("Tiled frame")
91     TR("Floating frame")
92     TR("Context menu:")
93     TR("Main menu:")
94 end