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