Consistency fixes
[notion.git] / ioncore / ioncore_ext.lua
blob3568c7e457a054773f71405aa734bfa8d7ae9c49
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 --META="Mod4+"
16 --ALTMETA=""
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 -- Historically, the options now called 'META' and 'ALTMETA' were called 'MOD1' and 'MOD2'.
35 -- The code below makes sure:
36 -- * the default values for those settings are 'Mod4+' (the 'windows key') and ''
37 -- * that setting either META/ALTMETA or MOD1/MOD2 will specify the primary and secondary meta keys
38 -- * that getting either META/ALTMETA or MOD1/MOD2 will return the (default or configured) primary and secondary meta keys
40 local function getmod(t, s)
41 if s=="META" then
42 return rawget(t, "MOD1") or "Mod4+"
43 elseif s=="MOD1" then
44 return rawget(t, "META") or "Mod4+"
45 elseif s=="ALTMETA" then
46 return rawget(t, "MOD2") or ""
47 elseif s=="MOD2" then
48 return rawget(t, "ALTMETA") or ""
49 elseif oldindex then
50 return oldindex(t, s)
51 end
52 end
54 local oldmeta, newmeta=getmetatable(_G), {}
55 if oldmeta then
56 newmeta=table.copy(oldmeta)
57 oldindex=oldmeta.__index
58 end
59 newmeta.__index=getmod
60 setmetatable(_G, newmeta)
62 notioncore = ioncore
64 -- Export some important functions into global namespace.
65 export(ioncore,
66 notioncore,
67 "submap",
68 "submap_enter",
69 "submap_wait",
70 "kpress",
71 "kpress_wait",
72 "mpress",
73 "mclick",
74 "mdblclick",
75 "mdrag",
76 "defbindings",
77 "defwinprop",
78 "warn",
79 "exec",
80 "TR",
81 "bdoc",
82 "defmenu",
83 "defctxmenu",
84 "menuentry",
85 "submenu")
87 -- Mark ourselves loaded.
88 package.loaded["ioncore"]=true
92 local function dummy_gettext_hack()
93 -- Extra translations for context menus etc. I don't want extra
94 -- TR calls in the configuration files, or parsing the string
95 -- parameters to kpress etc. for translations.
96 TR("Frame")
97 TR("Screen")
98 TR("Workspace")
99 TR("Tiling")
100 TR("Tiled frame")
101 TR("Floating frame")
102 TR("Context menu:")
103 TR("Main menu:")