1 -- Authors: James Gray <james@solitaryfield.org>, Etan Reisner <deryni@gmail.com>
3 -- Last Changed: 2007-06-22
6 Author: James Gray, Etan Reisner
7 Email: james at solitaryfield dot org, deryni@unreliablesource.net
9 Summary: Allows locking
11 Last Updated: Fri Jun 22 00:59:06 EDT 2007
15 -- F11 toggles the lock of keyboard close and resize on the currently active
17 -- META-F11 will save the name of the frame and lock it again in subsequent
20 -- You will need to rebind your close and kill bindings to use the
21 -- check_before_close and check_before_kill functions for this script to do
25 -- de.substyle("*-*-*-locked", {
26 -- background_colour = "yellow",
29 -- de.substyle("*-*-*-*-locked_saved", {
30 -- background_colour = "white",
32 -- to your theme's de.defstyle("tab-frame", {...}) style will cause locked and
33 -- locked+saved frames to be highlighted.
35 local locks
= setmetatable({}, {__mode
="k"})
38 function lock_frame(frame
, save
)
39 local name
= frame
:name()
43 frame
:set_grattr("locked", "unset")
45 frame
:set_grattr("locked_saved", "unset")
50 frame
:set_grattr("locked", "set")
52 frame
:set_grattr("locked_saved", "set")
58 function check_before_kill(reg
)
59 if not locks
[reg
] then
64 function check_before_close(reg
, sub
)
65 if (not locks
[reg
]) and (not locks
[sub
]) then
66 WRegion
.rqclose_propagate(reg
, sub
)
70 ioncore
.defbindings("WFrame",{
71 kpress("F11", "lock_frame(_)"),
72 kpress(META
.."F11", "lock_frame(_, true)")
75 function save_locked()
76 ioncore
.write_savefile("saved_lock_frame", saved
)
79 function load_locked()
80 local locked
= ioncore
.read_savefile("saved_lock_frame") or {}
82 for k
,v
in pairs(locked
) do
83 local reg
= ioncore
.lookup_region(k
)
88 local hook
= ioncore
.get_hook("ioncore_deinit_hook")