]> git.decadent.org.uk Git - ion3.git/blob - ioncore/ioncore_ext.lua
2255bdd37af2aa25f0de3fa8704348fa705930cb
[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 -- Ion is free software; you can redistribute it and/or modify it under
7 -- the terms of the GNU Lesser General Public License as published by
8 -- the Free Software Foundation; either version 2.1 of the License, or
9 -- (at your option) any later version.
10 --
11
12 -- This is a slight abuse of the package.loaded variable perhaps, but
13 -- library-like packages should handle checking if they're loaded instead of
14 -- confusing the user with require/includer differences.
15 if package.loaded["ioncore"] then return end
16
17 -- Default modifiers
18 --MOD1="Mod1+"
19 --MOD2=""
20
21 -- Maximum number of bytes to read from pipes
22 ioncore.RESULT_DATA_LIMIT=1024^2
23
24 -- Bindings, winprops, hooks, menu database and extra commands
25 dopath('ioncore_luaext')
26 dopath('ioncore_bindings')
27 dopath('ioncore_winprops')
28 dopath('ioncore_misc')
29 dopath('ioncore_wd')
30 dopath('ioncore_menudb')
31
32 -- Modifier setup compatibility kludge
33 local oldindex
34
35 local function getmod(t, s)
36     if s=="META" then
37         return rawget(t, "MOD1") or "Mod1+"
38     elseif s=="MOD1" then
39         return rawget(t, "META") or "Mod1+"
40     elseif s=="ALTMETA" then
41         return rawget(t, "MOD2") or ""
42     elseif s=="MOD2" then
43         return rawget(t, "ALTMETA") or ""
44     elseif oldindex then
45         return oldindex(t, s)
46     end
47 end
48
49 local oldmeta, newmeta=getmetatable(_G), {}
50 if oldmeta then
51     newmeta=table.copy(oldmeta)
52     oldindex=oldmeta.__index
53 end
54 newmeta.__index=getmod
55 setmetatable(_G, newmeta)
56
57 -- Export some important functions into global namespace.
58 export(ioncore, 
59        "submap",
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