Debian package: Use more debhelper magic
[conkeror.git] / modules / global-overlay-keymap.js
blobbca910497c94cf4ad2cdbb4320a6260af625fe2f
1 /**
2  * (C) Copyright 2008 Jeremy Maitin-Shepard
3  * (C) Copyright 2008-2009 John J. Foerch
4  *
5  * Use, modification, and distribution are subject to the terms specified in the
6  * COPYING file.
7 **/
9 require("input.js");
11 define_keymap("global_overlay_keymap");
14 function global_overlay_keymap_handler (window, I, true_event) {
15     var binding = keymap_lookup([global_overlay_keymap], I.combo, I.event);
16     if (!binding)
17         return false;
18     if (!binding.fallthrough)
19         event_kill(true_event);
20     I.key_sequence.pop();
21     if (binding.command)
22         co_call(call_interactively(I, binding.command));
23     return true;
27 define_global_mode("global_overlay_keymap_mode",
28                    function () {
29                        add_hook("keypress_hook", global_overlay_keymap_handler);
30                    },
31                    function () {
32                        remove_hook("keypress_hook", global_overlay_keymap_handler);
33                    });
36 function define_key_alias (typed_key, generated_key) {
37     var name = "generate-key-event:"+generated_key;
38     interactive(name,
39         "Generate a fake key press event for the key: "+generated_key,
40         function (I) {
41             call_after_timeout(function () {
42                 send_key_as_event(I.window,
43                                   I.buffer.focused_element,
44                                   generated_key);
45             }, 0);
46         });
47     define_key(global_overlay_keymap, typed_key, name);
48     global_overlay_keymap_mode(true);
50 ignore_function_for_get_caller_source_code_reference("define_key_alias");
53 function define_sticky_modifier (typed_key, modifiers) {
54     var name = "sticky-modifiers:"+modifiers;
55     interactive(name, "Set sticky modifiers: "+modifiers,
56                 function (I) {
57                     I.sticky_modifiers = modifiers;
58                 });
59     define_key(global_overlay_keymap, typed_key, name);
60     global_overlay_keymap_mode(true);
62 ignore_function_for_get_caller_source_code_reference("define_sticky_modifier");
64 provide("global-overlay-keymap");