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