2 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
3 * (C) Copyright 2008-2009 John J. Foerch
5 * Use, modification, and distribution are subject to the terms specified in the
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();
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);
32 buffer.modalities.splice(i, 1);
33 buffer.set_input_mode();
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);
46 add_hook('create_buffer_hook', caret_mode_enable);
48 for_each_buffer(function (buffer) {
49 caret_mode(buffer, false);
51 remove_hook('create_buffer_hook', caret_mode_enable);