]> git.gir.st - VimFx.git/blob - extension/lib/defaults.coffee
Merge branch 'master' into develop
[VimFx.git] / extension / lib / defaults.coffee
1 ###
2 # Copyright Simon Lydell 2015.
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 'gJ': 'tab_move_backward'
65 'gK': 'tab_move_forward'
66 'gw': 'tab_move_to_window'
67 'g0': 'tab_select_first'
68 'g^': 'tab_select_first_non_pinned'
69 'g$': 'tab_select_last'
70 'gp': 'tab_toggle_pinned'
71 'x': 'tab_close'
72 'X': 'tab_restore'
73 'gx$': 'tab_close_to_end'
74 'gxa': 'tab_close_other'
75
76 'browsing':
77 'f': 'follow'
78 'F': 'follow_in_tab'
79 'gf': 'follow_in_focused_tab'
80 'gF': 'follow_in_window'
81 'af': 'follow_multiple'
82 'yf': 'follow_copy'
83 'zf': 'follow_focus'
84 '[': 'follow_previous'
85 ']': 'follow_next'
86 'gi': 'focus_text_input'
87
88 'find':
89 '/': 'find'
90 'a/': 'find_highlight_all'
91 'g/': 'find_links_only'
92 'n': 'find_next'
93 'N': 'find_previous'
94
95 'misc':
96 'w': 'window_new'
97 'W': 'window_new_private'
98 'i': 'enter_mode_ignore'
99 'I': 'quote'
100 '?': 'help'
101 ':': 'dev'
102 '<force><escape>': 'esc'
103
104 'hints':
105 '':
106 '<escape>': 'exit'
107 '<space>': 'rotate_markers_forward'
108 '<s-space>': 'rotate_markers_backward'
109 '<backspace>': 'delete_hint_char'
110 '<enter>': 'increase_count'
111
112 'ignore':
113 '':
114 '<s-escape>': 'exit'
115 '<s-f1>': 'unquote'
116
117 'find':
118 '':
119 '<escape> <enter>': 'exit'
120
121 options =
122 'hint_chars': 'fjdkslaghrueiwovncm'
123 'prev_patterns': 'prev previous ‹ « ◀ ← << < back newer'
124 'next_patterns': 'next › » ▶ → >> > more older'
125 'black_list': ''
126 'prevent_autofocus': false
127 'ignore_keyboard_layout': false
128 'timeout': 2000
129
130 advanced_options =
131 'notifications_enabled': true
132 'prevent_target_blank': true
133 'prevent_autofocus_modes': 'normal'
134 'hints_timeout': 200
135 'smoothScroll.lines.spring-constant': '1000'
136 'smoothScroll.pages.spring-constant': '2500'
137 'smoothScroll.other.spring-constant': '2500'
138 'pattern_selector': 'a, button'
139 'pattern_attrs': 'rel role data-tooltip aria-label'
140 'last_scroll_position_mark': '`'
141 'hints_toggle_in_tab': '<c-'
142 'hints_toggle_in_background': '<a-'
143 'activatable_element_keys': '<enter>'
144 'adjustable_element_keys': '<arrowup> <arrowdown> <arrowleft>
145 <arrowright> <space> <enter>'
146 'focus_previous_key': '<s-tab>'
147 'focus_next_key': '<tab>'
148 'options.key.quote': '<c-q>'
149 'options.key.insert_default': '<c-d>'
150 'options.key.reset_default': '<c-r>'
151
152 parsed_options =
153 'translations': {}
154 'categories': {} # Will be filled in below.
155
156
157
158 # The above easy-to-read data is transformed in to easy-to-consume (for
159 # computers) formats below.
160
161 translate = require('./l10n')
162 utils = require('./utils')
163
164 addCategory = (category, order) ->
165 uncategorized = (category == '')
166 categoryName =
167 if uncategorized
168 -> ''
169 else
170 translate.bind(null, "category.#{category}")
171 parsed_options.categories[category] = {
172 name: categoryName
173 order: if uncategorized then 0 else order
174 }
175
176 shortcut_prefs = {}
177 categoryMap = {}
178 mode_order = {}
179 command_order = {}
180
181 createCounter = -> new utils.Counter({step: 100})
182 modeCounter = createCounter()
183 categoryCounter = createCounter()
184
185 for modeName, modeCategories of shortcuts
186 mode_order[modeName] = modeCounter.tick()
187 for categoryName, modeShortcuts of modeCategories
188 addCategory(categoryName, categoryCounter.tick())
189 commandIndex = createCounter()
190 for shortcut, commandName of modeShortcuts
191 pref = "mode.#{modeName}.#{commandName}"
192 shortcut_prefs[pref] = shortcut
193 command_order[pref] = commandIndex.tick()
194 categoryMap[pref] = categoryName
195
196 # All options, excluding shortcut customizations.
197 all_options = Object.assign({}, options, advanced_options, parsed_options)
198 # All things that are saved in Firefox’s prefs system.
199 all_prefs = Object.assign({}, options, advanced_options, shortcut_prefs)
200
201 module.exports = {
202 options
203 advanced_options
204 parsed_options
205 all_options
206 shortcut_prefs
207 all_prefs
208 categoryMap
209 mode_order
210 command_order
211 BRANCH: 'extensions.VimFx.'
212 }
Imprint / Impressum