]> git.gir.st - VimFx.git/blob - extension/lib/defaults.coffee
Major refactor: Rework all UI and related improvements
[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': 'text_input'
80
81 'find':
82 '/': 'find'
83 'a/': 'find_highlight_all'
84 'n': 'find_next'
85 'N': 'find_previous'
86
87 'misc':
88 'i': 'enter_mode_insert'
89 'I': 'quote'
90 '?': 'help'
91 ':': 'dev'
92 '<force><escape>': 'esc'
93
94 'hints':
95 '':
96 '<escape>': 'exit'
97 '<space>': 'rotate_markers_forward'
98 '<s-space>': 'rotate_markers_backward'
99 '<backspace>': 'delete_hint_char'
100
101 'insert':
102 '':
103 '<s-escape>': 'exit'
104
105 'text_input':
106 '':
107 '<escape>': 'exit'
108 '<s-tab>': 'input_previous'
109 '<tab>': 'input_next'
110
111 'find':
112 '':
113 '<escape> <enter>': 'exit'
114
115 options =
116 'hint_chars': 'fjdkslaghrueiwovncm'
117 'prev_patterns': 'prev previous ‹ « ◀ ← << < back newer'
118 'next_patterns': 'next › » ▶ → >> > more older'
119 'black_list': ''
120 'prevent_autofocus': true
121 'ignore_keyboard_layout': false
122 'timeout': 2000
123
124 advanced_options =
125 'prevent_target_blank': true
126 'autofocus_limit': 100
127 'hints_timeout': 200
128 'smoothScroll.lines.spring-constant': '1000'
129 'smoothScroll.pages.spring-constant': '2500'
130 'smoothScroll.other.spring-constant': '2500'
131 'pattern_selector': 'a, button'
132 'pattern_attrs': 'rel role data-tooltip aria-label'
133 'activatable_element_keys': '<enter>'
134 'adjustable_element_keys': '<arrowup> <arrowdown> <arrowleft>
135 <arrowright> <space> <enter>'
136 'options.key.quote': '<c-q>'
137 'options.key.insert_default': '<c-d>'
138 'options.key.reset_default': '<c-r>'
139
140 parsed_options =
141 'translations': {}
142 'categories': {} # Will be filled in below.
143
144
145
146 translate = require('./l10n')
147 utils = require('./utils')
148
149 addCategory = (category, order) ->
150 uncategorized = (category == '')
151 categoryName =
152 if uncategorized
153 -> ''
154 else
155 translate.bind(null, "category.#{ category }")
156 parsed_options.categories[category] = {
157 name: categoryName
158 order: if uncategorized then 0 else order
159 }
160
161 shortcut_prefs = {}
162 categoryMap = {}
163 mode_order = {}
164 command_order = {}
165
166 createCounter = -> new utils.Counter({step: 100})
167 modeCounter = createCounter()
168 categoryCounter = createCounter()
169
170 for modeName, modeCategories of shortcuts
171 mode_order[modeName] = modeCounter.tick()
172 for categoryName, modeShortcuts of modeCategories
173 addCategory(categoryName, categoryCounter.tick())
174 commandIndex = createCounter()
175 for shortcut, commandName of modeShortcuts
176 pref = "mode.#{ modeName }.#{ commandName }"
177 shortcut_prefs[pref] = shortcut
178 command_order[pref] = commandIndex.tick()
179 categoryMap[pref] = categoryName
180
181 # All options, excluding shortcut customizations.
182 all_options = Object.assign({}, options, advanced_options, parsed_options)
183 # All things that are saved in Firefox’s prefs system.
184 all_prefs = Object.assign({}, options, advanced_options, shortcut_prefs)
185
186 module.exports = {
187 options
188 advanced_options
189 parsed_options
190 all_options
191 shortcut_prefs
192 all_prefs
193 categoryMap
194 mode_order
195 command_order
196 BRANCH: 'extensions.VimFx.'
197 }
Imprint / Impressum