xkcd-mode: use buffer_loaded_hook instead of buffer_dom_content_loaded_hook
[conkeror.git] / modules / global-overlay-keymap.js
blob303941bec93c7ee18a293e681b4dd9ba56aa8582
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 in_module(null);
11 require("input.js");
13 define_keymap("global_overlay_keymap");
16 function global_overlay_keymap_handler (window, I, true_event) {
17     var binding = keymap_lookup([global_overlay_keymap], I.combo, I.event);
18     if (!binding)
19         return false;
20     if (!binding.fallthrough)
21         event_kill(true_event);
22     I.key_sequence.pop();
23     if (binding.command)
24         co_call(call_interactively(I, binding.command));
25     return true;
29 define_global_mode("global_overlay_keymap_mode",
30                    function () {
31                        add_hook("keypress_hook", global_overlay_keymap_handler);
32                    },
33                    function () {
34                        remove_hook("keypress_hook", global_overlay_keymap_handler);
35                    });
38 function define_key_alias (typed_key, generated_key) {
39     var name = "generate-key-event:"+generated_key;
40     interactive(name,
41         "Generate a fake key press event for the key: "+generated_key,
42         function (I) {
43             call_after_timeout(function () {
44                 send_key_as_event(I.window,
45                                   I.buffer.focused_element,
46                                   generated_key);
47             }, 0);
48         });
49     define_key(global_overlay_keymap, typed_key, name);
50     global_overlay_keymap_mode(true);
52 ignore_function_for_get_caller_source_code_reference("define_key_alias");
55 function define_sticky_modifier (typed_key, modifiers) {
56     var name = "sticky-modifiers:"+modifiers;
57     interactive(name, "Set sticky modifiers: "+modifiers,
58                 function (I) {
59                     I.sticky_modifiers = modifiers;
60                 });
61     define_key(global_overlay_keymap, typed_key, name);
62     global_overlay_keymap_mode(true);
64 ignore_function_for_get_caller_source_code_reference("define_sticky_modifier");
66 provide("global-overlay-keymap");