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
9 function caret_modality (buffer, elem) {
10 buffer.keymaps.push(caret_keymap);
13 define_buffer_mode('caret_mode',
14 function enable (buffer) {
15 buffer.browser.setAttribute('showcaret', 'true');
16 var sc = buffer.focused_selection_controller;
17 sc.setCaretEnabled(true);
18 buffer.top_frame.focus();
19 buffer.modalities.push(caret_modality);
20 buffer.set_input_mode();
22 function disable (buffer) {
23 buffer.browser.setAttribute('showcaret', 'false');
24 var sc = buffer.focused_selection_controller;
25 sc.setCaretEnabled(false);
26 buffer.browser.focus();
27 var i = buffer.modalities.indexOf(caret_modality);
29 buffer.modalities.splice(i, 1);
30 buffer.set_input_mode();
32 $display_name = 'CARET');
34 function caret_mode_enable (buffer) {
35 caret_mode.enable(buffer);
38 watch_pref('accessibility.browsewithcaret',
39 function caret_toggle_all_buffers () {
40 if (get_pref('accessibility.browsewithcaret')) {
41 for_each_buffer(function (buffer) {
42 caret_mode(buffer, true);
44 add_hook('create_buffer_hook', caret_mode_enable);
46 for_each_buffer(function (buffer) {
47 caret_mode(buffer, false);
49 remove_hook('create_buffer_hook', caret_mode_enable);