]> git.gir.st - VimFx.git/blob - extension/lib/defaults.coffee
Change default shortcuts for some hint commands
[VimFx.git] / extension / lib / defaults.coffee
1 ###
2 # Copyright Simon Lydell 2015, 2016.
3 #
4 # This file is part of VimFx.
5 #
6 # VimFx is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # VimFx is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with VimFx. If not, see <http://www.gnu.org/licenses/>.
18 ###
19
20 # coffeelint: disable=colon_assignment_spacing
21 # coffeelint: disable=no_implicit_braces
22
23 # This file defines all VimFx’s options in an easy-to-read way.
24
25 shortcuts =
26 'normal':
27 'location':
28 'o': 'focus_location_bar'
29 'O': 'focus_search_bar'
30 'p': 'paste_and_go'
31 'P': 'paste_and_go_in_tab'
32 'yy': 'copy_current_url'
33 'gu': 'go_up_path'
34 'gU': 'go_to_root'
35 'gh': 'go_home'
36 'H': 'history_back'
37 'L': 'history_forward'
38 'gH': 'history_list'
39 'r': 'reload'
40 'R': 'reload_force'
41 'ar': 'reload_all'
42 'aR': 'reload_all_force'
43 's': 'stop'
44 'as': 'stop_all'
45
46 'scrolling':
47 'h': 'scroll_left'
48 'l': 'scroll_right'
49 'j': 'scroll_down'
50 'k': 'scroll_up'
51 '<space>': 'scroll_page_down'
52 '<s-space>': 'scroll_page_up'
53 'd': 'scroll_half_page_down'
54 'u': 'scroll_half_page_up'
55 'gg': 'scroll_to_top'
56 'G': 'scroll_to_bottom'
57 '0 ^': 'scroll_to_left'
58 '$': 'scroll_to_right'
59 'm': 'mark_scroll_position'
60 '`': 'scroll_to_mark'
61
62 'tabs':
63 't': 'tab_new'
64 'T': 'tab_new_after_current'
65 'yt': 'tab_duplicate'
66 'J gT': 'tab_select_previous'
67 'K gt': 'tab_select_next'
68 'gl': 'tab_select_most_recent'
69 'gL': 'tab_select_oldest_unvisited'
70 'gJ': 'tab_move_backward'
71 'gK': 'tab_move_forward'
72 'gw': 'tab_move_to_window'
73 'g0': 'tab_select_first'
74 'g^': 'tab_select_first_non_pinned'
75 'g$': 'tab_select_last'
76 'gp': 'tab_toggle_pinned'
77 'x': 'tab_close'
78 'X': 'tab_restore'
79 'gX': 'tab_restore_list'
80 'gx$': 'tab_close_to_end'
81 'gxa': 'tab_close_other'
82
83 'browsing':
84 'f': 'follow'
85 'F': 'follow_in_tab'
86 'et': 'follow_in_focused_tab'
87 'ew': 'follow_in_window'
88 'af': 'follow_multiple'
89 'yf': 'follow_copy'
90 'ef': 'follow_focus'
91 'eb': 'click_browser_element'
92 '[': 'follow_previous'
93 ']': 'follow_next'
94 'gi': 'focus_text_input'
95 'v': 'element_text_caret'
96 'av': 'element_text_select'
97 'yv': 'element_text_copy'
98
99 'find':
100 '/': 'find'
101 'a/': 'find_highlight_all'
102 'g/': 'find_links_only'
103 'n': 'find_next'
104 'N': 'find_previous'
105
106 'misc':
107 'w': 'window_new'
108 'W': 'window_new_private'
109 'i': 'enter_mode_ignore'
110 'I': 'quote'
111 'gr': 'enter_reader_view'
112 'zr': 'reload_config_file'
113 '?': 'help'
114 ':': 'dev'
115 '<force><escape>': 'esc'
116
117 'caret':
118 '':
119 'h': 'move_left'
120 'l': 'move_right'
121 'j': 'move_down'
122 'k': 'move_up'
123 'b': 'move_word_left'
124 'w': 'move_word_right'
125 '0 ^': 'move_to_line_start'
126 '$': 'move_to_line_end'
127 'v': 'toggle_selection'
128 'o': 'toggle_selection_direction'
129 'y': 'copy_selection_and_exit'
130 '<escape>': 'exit'
131
132 'hints':
133 '':
134 '<escape>': 'exit'
135 '<space>': 'rotate_markers_forward'
136 '<s-space>': 'rotate_markers_backward'
137 '<backspace>': 'delete_hint_char'
138 '<enter>': 'increase_count'
139 '<c-enter>': 'toggle_complementary'
140
141 'ignore':
142 '':
143 '<s-escape>': 'exit'
144 '<s-f1>': 'unquote'
145
146 'find':
147 '':
148 '<escape> <enter>': 'exit'
149
150 'marks':
151 '':
152 '<escape> ': 'exit'
153
154 options =
155 'hint_chars': 'fjdkslaghrueiwonc mv'
156 'prev_patterns': 'prev previous ‹ « ◀ ← << < back newer'
157 'next_patterns': 'next › » ▶ → >> > more older'
158 'blacklist': '*example.com* http://example.org/editor/*'
159 'prevent_autofocus': false
160 'ignore_keyboard_layout': false
161 'timeout': 2000
162
163 advanced_options =
164 'notifications_enabled': true
165 'notify_entered_keys': true
166 'prevent_target_blank': true
167 'counts_enabled': true
168 'find_from_top_of_viewport': true
169 'ignore_ctrl_alt': (Services.appinfo.OS == 'WINNT')
170 'prevent_autofocus_modes': 'normal'
171 'config_file_directory': ''
172 'blur_timeout': 50
173 'hints_timeout': 200
174 'hints_sleep': 15
175 'smoothScroll.lines.spring-constant': '1000'
176 'smoothScroll.pages.spring-constant': '2500'
177 'smoothScroll.other.spring-constant': '2500'
178 'scroll.reset_timeout': 1000
179 'scroll.full_page_adjustment': 40
180 'scroll.half_page_adjustment': 20
181 'scroll.last_position_mark': '`'
182 'pattern_selector': ':-moz-any(
183 a, button, input[type="button"]
184 ):not([role="menu"]):not([role="tab"])'
185 'pattern_attrs': 'rel role data-tooltip aria-label'
186 'hints_peek_through': '<s->'
187 'hints_toggle_in_tab': '<c-'
188 'hints_toggle_in_background': '<a-'
189 'activatable_element_keys': '<enter>'
190 'adjustable_element_keys': '<arrowup> <arrowdown> <arrowleft>
191 <arrowright> <space> <enter>'
192 'focus_previous_key': '<s-tab>'
193 'focus_next_key': '<tab>'
194 'options.key.quote': '<c-q>'
195 'options.key.insert_default': '<c-d>'
196 'options.key.reset_default': '<c-r>'
197
198 parsed_options =
199 'translations': {}
200 'categories': {} # Will be filled in below.
201
202
203
204 # The above easy-to-read data is transformed in to easy-to-consume (for
205 # computers) formats below.
206
207 # coffeelint: enable=colon_assignment_spacing
208 # coffeelint: enable=no_implicit_braces
209
210 translate = require('./translate')
211 utils = require('./utils')
212
213 addCategory = (category, order) ->
214 uncategorized = (category == '')
215 categoryName = if uncategorized then '' else translate("category.#{category}")
216 parsed_options.categories[category] = {
217 name: categoryName
218 order: if uncategorized then 0 else order
219 }
220
221 shortcut_prefs = {}
222 categoryMap = {}
223 mode_order = {}
224 command_order = {}
225
226 createCounter = -> new utils.Counter({step: 100})
227 modeCounter = createCounter()
228 categoryCounter = createCounter()
229
230 for modeName, modeCategories of shortcuts
231 mode_order[modeName] = modeCounter.tick()
232 for categoryName, modeShortcuts of modeCategories
233 addCategory(categoryName, categoryCounter.tick())
234 commandIndex = createCounter()
235 for shortcut, commandName of modeShortcuts
236 pref = "mode.#{modeName}.#{commandName}"
237 shortcut_prefs[pref] = shortcut
238 command_order[pref] = commandIndex.tick()
239 categoryMap[pref] = categoryName
240
241 # All options, excluding shortcut customizations.
242 all_options = Object.assign({}, options, advanced_options, parsed_options)
243 # All things that are saved in Firefox’s prefs system.
244 all_prefs = Object.assign({}, options, advanced_options, shortcut_prefs)
245
246 module.exports = {
247 options
248 advanced_options
249 parsed_options
250 all_options
251 shortcut_prefs
252 all_prefs
253 categoryMap
254 mode_order
255 command_order
256 BRANCH: 'extensions.VimFx.'
257 }
Imprint / Impressum