No longer trap fatal signals
[notion/jeffpc.git] / contrib / scripts / switch_bindings.lua
blobcdc750bafa998708bde89becfbffeabe1d0a85f3
1 -- Authors: Sadrul Habib Chowdhury <imadil@gmail.com>, Canaan Hadley-Voth
2 -- License: Public domain
3 -- Last Changed: Unknown
4 --
5 -- switch_bindings.lua
6 --
7 -- Switch between different set of keybindings. You can use it to temporarily
8 -- disable the keybindings by pressing META+F8. All the subsequent keystrokes
9 -- will be sent to the application, until you press META+F8 again, at which
10 -- point the previous bindings will be restored.
12 -- Author: Sadrul Habib Chowdhury (Adil) <imadil |at| gmail |dot| com>
13 -- Adjustments by: Canaan Hadley-Voth
17 -- second set of bindings
19 local alternate = {
20 WScreen = {
21 kpress(META.."F8", "toggle_bindings()"),
25 function toggle_bindings()
26 local save = table.copy(ioncore.getbindings(), true)
27 local kcb_area
29 -- First empty all the bindings
30 for name, bindings in pairs(save) do
31 for index, bind in pairs(bindings) do
32 if bind.area then
33 kcb_area = bind.kcb.."@"..bind.area
34 else
35 kcb_area = bind.kcb
36 end
37 -- This can most definitely be improved
38 if bind.action == "kpress" then
39 ioncore.defbindings(name, {kpress(bind.kcb, nil)})
40 -- "kpress_wairel" appearing as bind.action
41 elseif string.find(bind.action, "kpress_wai") then
42 ioncore.defbindings(name, {kpress_wait(bind.kcb, nil)})
43 elseif bind.action == "mpress" then
44 ioncore.defbindings(name, {mpress(kcb_area, nil)})
45 elseif bind.action == "mdrag" then
46 ioncore.defbindings(name, {mdrag(kcb_area, nil)})
47 elseif bind.action == "mclick" then
48 ioncore.defbindings(name, {mclick(kcb_area, nil)})
49 elseif bind.action == "mdblclick" then
50 ioncore.defbindings(name, {mdblclick(kcb_area, nil)})
51 end
52 end
53 end
55 -- Store the last saved on
56 for a, b in pairs(alternate) do
57 ioncore.defbindings(a, b)
58 end
60 alternate = save
61 end
63 ioncore.defbindings("WScreen", {
64 kpress(META.."F8", "toggle_bindings()"),