]> git.gir.st - VimFx.git/blob - extension/lib/defaults.coffee
Improve scrolling when holding h/l/j/k down
[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 'ep': 'follow_in_private_window'
89 'af': 'follow_multiple'
90 'yf': 'follow_copy'
91 'ef': 'follow_focus'
92 'ec': 'open_context_menu'
93 'eb': 'click_browser_element'
94 '[': 'follow_previous'
95 ']': 'follow_next'
96 'gi': 'focus_text_input'
97 'v': 'element_text_caret'
98 'av': 'element_text_select'
99 'yv': 'element_text_copy'
100
101 'find':
102 '/': 'find'
103 'a/': 'find_highlight_all'
104 'g/': 'find_links_only'
105 'n': 'find_next'
106 'N': 'find_previous'
107
108 'misc':
109 'w': 'window_new'
110 'W': 'window_new_private'
111 'i': 'enter_mode_ignore'
112 'I': 'quote'
113 'gr': 'enter_reader_view'
114 'gB': 'edit_blacklist'
115 'gC': 'reload_config_file'
116 '?': 'help'
117 ':': 'dev'
118 '<force><escape>': 'esc'
119
120 'caret':
121 '':
122 'h': 'move_left'
123 'l': 'move_right'
124 'j': 'move_down'
125 'k': 'move_up'
126 'b': 'move_word_left'
127 'w': 'move_word_right'
128 '0 ^': 'move_to_line_start'
129 '$': 'move_to_line_end'
130 'v': 'toggle_selection'
131 'o': 'toggle_selection_direction'
132 'y': 'copy_selection_and_exit'
133 '<escape>': 'exit'
134
135 'hints':
136 '':
137 '<escape>': 'exit'
138 '<enter> \
139 <c-enter> \
140 <a-enter>': 'activate_highlighted'
141 '<c-space>': 'rotate_markers_forward'
142 '<s-space>': 'rotate_markers_backward'
143 '<backspace>': 'delete_char'
144 '<c-backspace>': 'toggle_complementary'
145 '<up>': 'increase_count'
146
147 'ignore':
148 '':
149 '<s-escape>': 'exit'
150 '<s-f1>': 'unquote'
151
152 'find':
153 '':
154 '<escape> <enter>': 'exit'
155
156 'marks':
157 '':
158 '<escape> ': 'exit'
159
160 options =
161 'prevent_autofocus': false
162 'ignore_keyboard_layout': false
163 'blacklist': '*example.com* http://example.org/editor/*'
164 'hints.chars': 'fjdkslaghrueiwonc mv'
165 'hints.auto_activate': true
166 'hints.timeout': 400
167 'timeout': 2000
168 'prev_patterns': 'prev previous ‹ « ◀ ← << < back newer'
169 'next_patterns': 'next › » ▶ → >> > more older'
170
171 advanced_options =
172 'notifications_enabled': true
173 'notify_entered_keys': true
174 'prevent_target_blank': true
175 'counts_enabled': true
176 'find_from_top_of_viewport': true
177 'ignore_ctrl_alt': (Services.appinfo.OS == 'WINNT')
178 'prevent_autofocus_modes': 'normal'
179 'config_file_directory': ''
180 'blur_timeout': 50
181 'smoothScroll.lines.spring-constant': '1000'
182 'smoothScroll.pages.spring-constant': '2500'
183 'smoothScroll.other.spring-constant': '2500'
184 'scroll.reset_timeout': 1000
185 'scroll.horizontal_boost': 6
186 'scroll.vertical_boost': 3
187 'scroll.full_page_adjustment': 40
188 'scroll.half_page_adjustment': 20
189 'scroll.last_position_mark': "'"
190 'pattern_selector': ':-moz-any(
191 a, button, input[type="button"]
192 ):not([role="menu"]):not([role="tab"])'
193 'pattern_attrs': 'rel role data-tooltip aria-label'
194 'hints.matched_timeout': 200
195 'hints.sleep': 15
196 'hints.match_text': true
197 'hints.peek_through': '<c-s->'
198 'hints.toggle_in_tab': '<c-'
199 'hints.toggle_in_background': '<a-'
200 'activatable_element_keys': '<enter>'
201 'adjustable_element_keys': '<arrowup> <arrowdown> <arrowleft>
202 <arrowright> <space> <enter>'
203 'focus_previous_key': '<s-tab>'
204 'focus_next_key': '<tab>'
205 'options.key.quote': '<c-q>'
206 'options.key.insert_default': '<c-d>'
207 'options.key.reset_default': '<c-r>'
208
209 parsed_options =
210 'translations': {}
211 'categories': {} # Will be filled in below.
212
213
214
215 # The above easy-to-read data is transformed in to easy-to-consume (for
216 # computers) formats below.
217
218 # coffeelint: enable=colon_assignment_spacing
219 # coffeelint: enable=no_implicit_braces
220
221 translate = require('./translate')
222 utils = require('./utils')
223
224 addCategory = (category, order) ->
225 uncategorized = (category == '')
226 categoryName = if uncategorized then '' else translate("category.#{category}")
227 parsed_options.categories[category] = {
228 name: categoryName
229 order: if uncategorized then 0 else order
230 }
231
232 shortcut_prefs = {}
233 categoryMap = {}
234 mode_order = {}
235 command_order = {}
236
237 createCounter = -> new utils.Counter({step: 100})
238 modeCounter = createCounter()
239 categoryCounter = createCounter()
240
241 for modeName, modeCategories of shortcuts
242 mode_order[modeName] = modeCounter.tick()
243 for categoryName, modeShortcuts of modeCategories
244 addCategory(categoryName, categoryCounter.tick())
245 commandIndex = createCounter()
246 for shortcut, commandName of modeShortcuts
247 pref = "mode.#{modeName}.#{commandName}"
248 shortcut_prefs[pref] = shortcut
249 command_order[pref] = commandIndex.tick()
250 categoryMap[pref] = categoryName
251
252 # All options, excluding shortcut customizations.
253 all_options = Object.assign({}, options, advanced_options, parsed_options)
254 # All things that are saved in Firefox’s prefs system.
255 all_prefs = Object.assign({}, options, advanced_options, shortcut_prefs)
256
257 module.exports = {
258 options
259 advanced_options
260 parsed_options
261 all_options
262 shortcut_prefs
263 all_prefs
264 categoryMap
265 mode_order
266 command_order
267 BRANCH: 'extensions.VimFx.'
268 }
Imprint / Impressum