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