minibuffer: align baselines of prompt and input
[conkeror/arlinius.git] / modules / caret.js
blob804b224015c23ea5b163eae05617d61397cb96bc
1 /**
2  * (C) Copyright 2007-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 function caret_modality (buffer, elem) {
12     buffer.keymaps.push(caret_keymap);
15 define_buffer_mode('caret_mode',
16     $display_name = 'CARET',
17     $enable = function (buffer) {
18         buffer.browser.setAttribute('showcaret', 'true');
19         var sc = buffer.focused_selection_controller;
20         sc.setCaretEnabled(true);
21         buffer.top_frame.focus();
22         buffer.modalities.push(caret_modality);
23         buffer.set_input_mode();
24     },
25     $disable = function (buffer) {
26         buffer.browser.setAttribute('showcaret', 'false');
27         var sc = buffer.focused_selection_controller;
28         sc.setCaretEnabled(false);
29         buffer.browser.focus();
30         var i = buffer.modalities.indexOf(caret_modality);
31         if (i > -1)
32             buffer.modalities.splice(i, 1);
33         buffer.set_input_mode();
34     });
36 function caret_mode_enable (buffer) {
37     caret_mode(buffer, true);
40 watch_pref('accessibility.browsewithcaret',
41            function caret_toggle_all_buffers () {
42                if (get_pref('accessibility.browsewithcaret')) {
43                    for_each_buffer(function (buffer) {
44                        caret_mode(buffer, true);
45                    });
46                    add_hook('create_buffer_hook', caret_mode_enable);
47                } else {
48                    for_each_buffer(function (buffer) {
49                        caret_mode(buffer, false);
50                    });
51                    remove_hook('create_buffer_hook', caret_mode_enable);
52                }
53            });
55 provide("caret");