]> git.gir.st - VimFx.git/blob - extension/lib/defaults.coffee
Use strings instead of functions in the `modes` object
[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 # This file defines all VimFx’s options in an easy-to-read way.
21
22 shortcuts =
23 'normal':
24 'location':
25 'o': 'focus_location_bar'
26 'O': 'focus_search_bar'
27 'p': 'paste_and_go'
28 'P': 'paste_and_go_in_tab'
29 'yy': 'copy_current_url'
30 'gu': 'go_up_path'
31 'gU': 'go_to_root'
32 'gh': 'go_home'
33 'H': 'history_back'
34 'L': 'history_forward'
35 'gH': 'history_list'
36 'r': 'reload'
37 'R': 'reload_force'
38 'ar': 'reload_all'
39 'aR': 'reload_all_force'
40 's': 'stop'
41 'as': 'stop_all'
42
43 'scrolling':
44 'h': 'scroll_left'
45 'l': 'scroll_right'
46 'j': 'scroll_down'
47 'k': 'scroll_up'
48 '<space>': 'scroll_page_down'
49 '<s-space>': 'scroll_page_up'
50 'd': 'scroll_half_page_down'
51 'u': 'scroll_half_page_up'
52 'gg': 'scroll_to_top'
53 'G': 'scroll_to_bottom'
54 '0 ^': 'scroll_to_left'
55 '$': 'scroll_to_right'
56 'm': 'mark_scroll_position'
57 '`': 'scroll_to_mark'
58
59 'tabs':
60 't': 'tab_new'
61 'yt': 'tab_duplicate'
62 'J gT': 'tab_select_previous'
63 'K gt': 'tab_select_next'
64 'gl': 'tab_select_most_recent'
65 'gJ': 'tab_move_backward'
66 'gK': 'tab_move_forward'
67 'gw': 'tab_move_to_window'
68 'g0': 'tab_select_first'
69 'g^': 'tab_select_first_non_pinned'
70 'g$': 'tab_select_last'
71 'gp': 'tab_toggle_pinned'
72 'x': 'tab_close'
73 'X': 'tab_restore'
74 'gX': 'tab_restore_list'
75 'gx$': 'tab_close_to_end'
76 'gxa': 'tab_close_other'
77
78 'browsing':
79 'f': 'follow'
80 'F': 'follow_in_tab'
81 'gf': 'follow_in_focused_tab'
82 'gF': 'follow_in_window'
83 'af': 'follow_multiple'
84 'yf': 'follow_copy'
85 'zf': 'follow_focus'
86 'zF': 'click_browser_element'
87 '[': 'follow_previous'
88 ']': 'follow_next'
89 'gi': 'focus_text_input'
90
91 'find':
92 '/': 'find'
93 'a/': 'find_highlight_all'
94 'g/': 'find_links_only'
95 'n': 'find_next'
96 'N': 'find_previous'
97
98 'misc':
99 'w': 'window_new'
100 'W': 'window_new_private'
101 'i': 'enter_mode_ignore'
102 'I': 'quote'
103 'gr': 'enter_reader_view'
104 '?': 'help'
105 ':': 'dev'
106 '<force><escape>': 'esc'
107
108 'hints':
109 '':
110 '<escape>': 'exit'
111 '<space>': 'rotate_markers_forward'
112 '<s-space>': 'rotate_markers_backward'
113 '<backspace>': 'delete_hint_char'
114 '<enter>': 'increase_count'
115
116 'ignore':
117 '':
118 '<s-escape>': 'exit'
119 '<s-f1>': 'unquote'
120
121 'find':
122 '':
123 '<escape> <enter>': 'exit'
124
125 options =
126 'hint_chars': 'fjdkslaghrueiwovncm'
127 'prev_patterns': 'prev previous ‹ « ◀ ← << < back newer'
128 'next_patterns': 'next › » ▶ → >> > more older'
129 'black_list': ''
130 'prevent_autofocus': false
131 'ignore_keyboard_layout': false
132 'timeout': 2000
133
134 advanced_options =
135 'notifications_enabled': true
136 'notify_entered_keys': true
137 'prevent_target_blank': true
138 'counts_enabled': true
139 'ignore_ctrl_alt': (Services.appinfo.OS == 'WINNT')
140 'prevent_autofocus_modes': 'normal'
141 'hints_timeout': 200
142 'smoothScroll.lines.spring-constant': '1000'
143 'smoothScroll.pages.spring-constant': '2500'
144 'smoothScroll.other.spring-constant': '2500'
145 'scroll.full_page_adjustment': 40
146 'scroll.half_page_adjustment': 20
147 'scroll.last_position_mark': '`'
148 'pattern_selector': ':-moz-any(
149 a, button, input[type="button"]
150 ):not([role="menu"]):not([role="tab"])'
151 'pattern_attrs': 'rel role data-tooltip aria-label'
152 'hints_toggle_in_tab': '<c-'
153 'hints_toggle_in_background': '<a-'
154 'activatable_element_keys': '<enter>'
155 'adjustable_element_keys': '<arrowup> <arrowdown> <arrowleft>
156 <arrowright> <space> <enter>'
157 'focus_previous_key': '<s-tab>'
158 'focus_next_key': '<tab>'
159 'options.key.quote': '<c-q>'
160 'options.key.insert_default': '<c-d>'
161 'options.key.reset_default': '<c-r>'
162
163 parsed_options =
164 'translations': {}
165 'categories': {} # Will be filled in below.
166
167
168
169 # The above easy-to-read data is transformed in to easy-to-consume (for
170 # computers) formats below.
171
172 translate = require('./l10n')
173 utils = require('./utils')
174
175 addCategory = (category, order) ->
176 uncategorized = (category == '')
177 categoryName = if uncategorized then '' else translate("category.#{category}")
178 parsed_options.categories[category] = {
179 name: categoryName
180 order: if uncategorized then 0 else order
181 }
182
183 shortcut_prefs = {}
184 categoryMap = {}
185 mode_order = {}
186 command_order = {}
187
188 createCounter = -> new utils.Counter({step: 100})
189 modeCounter = createCounter()
190 categoryCounter = createCounter()
191
192 for modeName, modeCategories of shortcuts
193 mode_order[modeName] = modeCounter.tick()
194 for categoryName, modeShortcuts of modeCategories
195 addCategory(categoryName, categoryCounter.tick())
196 commandIndex = createCounter()
197 for shortcut, commandName of modeShortcuts
198 pref = "mode.#{modeName}.#{commandName}"
199 shortcut_prefs[pref] = shortcut
200 command_order[pref] = commandIndex.tick()
201 categoryMap[pref] = categoryName
202
203 # All options, excluding shortcut customizations.
204 all_options = Object.assign({}, options, advanced_options, parsed_options)
205 # All things that are saved in Firefox’s prefs system.
206 all_prefs = Object.assign({}, options, advanced_options, shortcut_prefs)
207
208 module.exports = {
209 options
210 advanced_options
211 parsed_options
212 all_options
213 shortcut_prefs
214 all_prefs
215 categoryMap
216 mode_order
217 command_order
218 BRANCH: 'extensions.VimFx.'
219 }
Imprint / Impressum