]> git.gir.st - VimFx.git/blob - extension/lib/commands.coffee
Consistently name the translation ID for the `yy` notification
[VimFx.git] / extension / lib / commands.coffee
1 ###
2 # Copyright Anton Khodakivskiy 2012, 2013, 2014.
3 # Copyright Simon Lydell 2013, 2014, 2015, 2016.
4 # Copyright Wang Zhuochun 2013, 2014.
5 #
6 # This file is part of VimFx.
7 #
8 # VimFx is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # VimFx is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with VimFx. If not, see <http://www.gnu.org/licenses/>.
20 ###
21
22 # This file defines all Normal mode commands. Commands that need to interact
23 # with web page content do so by running `vim._run(name)`, which invokes `name`
24 # in commands-frame.coffee.
25
26 # NOTE: Most tab related commands need to do their actual tab manipulations in
27 # the next tick (`utils.nextTick`) to work around bug 1200334.
28
29 config = require('./config')
30 help = require('./help')
31 hints = require('./hints')
32 prefs = require('./prefs')
33 translate = require('./l10n')
34 utils = require('./utils')
35
36 commands = {}
37
38
39
40 commands.focus_location_bar = ({vim}) ->
41 vim.window.focusAndSelectUrlBar()
42
43 commands.focus_search_bar = ({vim, count}) ->
44 # The `.webSearch()` method opens a search engine in a tab if the search bar
45 # has been removed. Therefore we first check if it exists.
46 if vim.window.BrowserSearch.searchBar
47 vim.window.BrowserSearch.webSearch()
48 else
49 vim.notify(translate('notification.focus_search_bar.none'))
50
51 helper_paste_and_go = (props, {vim}) ->
52 {gURLBar} = vim.window
53 gURLBar.value = vim.window.readFromClipboard()
54 gURLBar.handleCommand(new vim.window.KeyboardEvent('keydown', props))
55
56 commands.paste_and_go = helper_paste_and_go.bind(null, null)
57
58 commands.paste_and_go_in_tab = helper_paste_and_go.bind(null, {altKey: true})
59
60 commands.copy_current_url = ({vim}) ->
61 utils.writeToClipboard(vim.window.gBrowser.currentURI.spec)
62 vim.notify(translate('notification.copy_current_url.success'))
63
64 commands.go_up_path = ({vim, count}) ->
65 vim._run('go_up_path', {count})
66
67 commands.go_to_root = ({vim}) ->
68 vim._run('go_to_root')
69
70 commands.go_home = ({vim}) ->
71 vim.window.BrowserHome()
72
73 helper_go_history = (direction, {vim, count = 1}) ->
74 {window} = vim
75 {SessionStore, gBrowser} = window
76
77 if (direction == 'back' and not gBrowser.canGoBack) or
78 (direction == 'forward' and not gBrowser.canGoForward)
79 vim.notify(translate("notification.history_#{direction}.limit"))
80 return
81
82 # `SessionStore.getSessionHistory()` (used below to support counts) starts
83 # lots of asynchronous tasks internally, which is a bit unreliable, it has
84 # turned out. The primary use of the `history_back` and `history_forward`
85 # commands is to go _one_ step back or forward, though, so those cases are
86 # optimized to use more reliable ways of going back and forward. Also, some
87 # extensions override the following functions, so calling them also gives
88 # better interoperability.
89 if count == 1
90 if direction == 'back'
91 window.BrowserBack()
92 else
93 window.BrowserForward()
94 return
95
96 SessionStore.getSessionHistory(gBrowser.selectedTab, (sessionHistory) ->
97 {index} = sessionHistory
98 newIndex = index + count * (if direction == 'back' then -1 else 1)
99 newIndex = Math.max(newIndex, 0)
100 newIndex = Math.min(newIndex, sessionHistory.entries.length - 1)
101 gBrowser.gotoIndex(newIndex)
102 )
103
104 commands.history_back = helper_go_history.bind(null, 'back')
105
106 commands.history_forward = helper_go_history.bind(null, 'forward')
107
108 commands.history_list = ({vim}) ->
109 menu = vim.window.document.getElementById('backForwardMenu')
110 utils.openPopup(menu)
111 if menu.childElementCount == 0
112 vim.notify(translate('notification.history_list.none'))
113
114 commands.reload = ({vim}) ->
115 vim.window.BrowserReload()
116
117 commands.reload_force = ({vim}) ->
118 vim.window.BrowserReloadSkipCache()
119
120 commands.reload_all = ({vim}) ->
121 vim.window.gBrowser.reloadAllTabs()
122
123 commands.reload_all_force = ({vim}) ->
124 for tab in vim.window.gBrowser.visibleTabs
125 gBrowser = tab.linkedBrowser
126 consts = gBrowser.webNavigation
127 flags = consts.LOAD_FLAGS_BYPASS_PROXY | consts.LOAD_FLAGS_BYPASS_CACHE
128 gBrowser.reload(flags)
129 return
130
131 commands.stop = ({vim}) ->
132 vim.window.BrowserStop()
133
134 commands.stop_all = ({vim}) ->
135 for tab in vim.window.gBrowser.visibleTabs
136 tab.linkedBrowser.stop()
137 return
138
139
140
141 helper_scroll = (vim, uiEvent, args...) ->
142 [
143 method, type, directions, amounts
144 properties = null, adjustment = 0, name = 'scroll'
145 ] = args
146 options = {
147 method, type, directions, amounts, properties, adjustment
148 smooth: (prefs.root.get('general.smoothScroll') and
149 prefs.root.get("general.smoothScroll.#{type}"))
150 }
151 reset = prefs.root.tmp(
152 'layout.css.scroll-behavior.spring-constant',
153 vim.options["smoothScroll.#{type}.spring-constant"]
154 )
155
156 helpScroll = help.getHelp(vim.window)?.querySelector('.wrapper')
157 if uiEvent or helpScroll
158 activeElement = helpScroll or utils.getActiveElement(vim.window)
159 if vim._state.scrollableElements.has(activeElement) or helpScroll
160 utils.scroll(activeElement, options)
161 reset()
162 return
163
164 vim._run(name, options, reset)
165
166
167 helper_scrollByLinesX = (amount, {vim, uiEvent, count = 1}) ->
168 distance = prefs.root.get('toolkit.scrollbox.horizontalScrollDistance')
169 helper_scroll(vim, uiEvent, 'scrollBy', 'lines', ['left'],
170 [amount * distance * count * 5])
171
172 helper_scrollByLinesY = (amount, {vim, uiEvent, count = 1}) ->
173 distance = prefs.root.get('toolkit.scrollbox.verticalScrollDistance')
174 helper_scroll(vim, uiEvent, 'scrollBy', 'lines', ['top'],
175 [amount * distance * count * 20])
176
177 helper_scrollByPagesY = (amount, type, {vim, uiEvent, count = 1}) ->
178 adjustment = vim.options["scroll.#{type}_page_adjustment"]
179 helper_scroll(vim, uiEvent, 'scrollBy', 'pages', ['top'],
180 [amount * count], ['clientHeight'], adjustment)
181
182 helper_scrollToX = (amount, {vim, uiEvent}) ->
183 helper_scroll(vim, uiEvent, 'scrollTo', 'other', ['left'],
184 [amount], ['scrollLeftMax'])
185 helper_mark_last_scroll_position(vim)
186
187 helper_scrollToY = (amount, {vim, uiEvent}) ->
188 helper_scroll(vim, uiEvent, 'scrollTo', 'other', ['top'],
189 [amount], ['scrollTopMax'])
190 helper_mark_last_scroll_position(vim)
191
192 commands.scroll_left = helper_scrollByLinesX.bind(null, -1)
193 commands.scroll_right = helper_scrollByLinesX.bind(null, +1)
194 commands.scroll_down = helper_scrollByLinesY.bind(null, +1)
195 commands.scroll_up = helper_scrollByLinesY.bind(null, -1)
196 commands.scroll_page_down = helper_scrollByPagesY.bind(null, +1, 'full')
197 commands.scroll_page_up = helper_scrollByPagesY.bind(null, -1, 'full')
198 commands.scroll_half_page_down = helper_scrollByPagesY.bind(null, +0.5, 'half')
199 commands.scroll_half_page_up = helper_scrollByPagesY.bind(null, -0.5, 'half')
200 commands.scroll_to_top = helper_scrollToY.bind(null, 0)
201 commands.scroll_to_bottom = helper_scrollToY.bind(null, Infinity)
202 commands.scroll_to_left = helper_scrollToX.bind(null, 0)
203 commands.scroll_to_right = helper_scrollToX.bind(null, Infinity)
204
205 helper_mark_last_scroll_position = (vim) ->
206 keyStr = vim.options['scroll.last_position_mark']
207 vim._run('mark_scroll_position', {keyStr, notify: false})
208
209 commands.mark_scroll_position = ({vim}) ->
210 vim.enterMode('marks', (keyStr) -> vim._run('mark_scroll_position', {keyStr}))
211
212 commands.scroll_to_mark = ({vim}) ->
213 vim.enterMode('marks', (keyStr) ->
214 unless keyStr == vim.options['scroll.last_position_mark']
215 helper_mark_last_scroll_position(vim)
216 helper_scroll(vim, null, 'scrollTo', 'other', ['top', 'left'], keyStr,
217 ['scrollTopMax', 'scrollLeftMax'], 0, 'scroll_to_mark')
218 )
219
220
221
222 commands.tab_new = ({vim}) ->
223 utils.nextTick(vim.window, ->
224 vim.window.BrowserOpenTab()
225 )
226
227 commands.tab_new_after_current = ({vim}) ->
228 {window} = vim
229 newTabPosition = window.gBrowser.selectedTab._tPos + 1
230 utils.nextTick(window, ->
231 utils.listenOnce(window, 'TabOpen', (event) ->
232 newTab = event.originalTarget
233 window.gBrowser.moveTabTo(newTab, newTabPosition)
234 )
235 window.BrowserOpenTab()
236 )
237
238 commands.tab_duplicate = ({vim}) ->
239 {gBrowser} = vim.window
240 utils.nextTick(vim.window, ->
241 gBrowser.duplicateTab(gBrowser.selectedTab)
242 )
243
244 absoluteTabIndex = (relativeIndex, gBrowser, {pinnedSeparate}) ->
245 tabs = gBrowser.visibleTabs
246 {selectedTab} = gBrowser
247
248 currentIndex = tabs.indexOf(selectedTab)
249 absoluteIndex = currentIndex + relativeIndex
250 numTabsTotal = tabs.length
251 numPinnedTabs = gBrowser._numPinnedTabs
252
253 [numTabs, min] = switch
254 when not pinnedSeparate
255 [numTabsTotal, 0]
256 when selectedTab.pinned
257 [numPinnedTabs, 0]
258 else
259 [numTabsTotal - numPinnedTabs, numPinnedTabs]
260
261 # Wrap _once_ if at one of the ends of the tab bar and cannot move in the
262 # current direction.
263 if (relativeIndex < 0 and currentIndex == min) or
264 (relativeIndex > 0 and currentIndex == min + numTabs - 1)
265 if absoluteIndex < min
266 absoluteIndex += numTabs
267 else if absoluteIndex >= min + numTabs
268 absoluteIndex -= numTabs
269
270 absoluteIndex = Math.max(min, absoluteIndex)
271 absoluteIndex = Math.min(absoluteIndex, min + numTabs - 1)
272
273 return absoluteIndex
274
275 helper_switch_tab = (direction, {vim, count = 1}) ->
276 {gBrowser} = vim.window
277 index = absoluteTabIndex(direction * count, gBrowser, {pinnedSeparate: false})
278 utils.nextTick(vim.window, ->
279 gBrowser.selectTabAtIndex(index)
280 )
281
282 commands.tab_select_previous = helper_switch_tab.bind(null, -1)
283
284 commands.tab_select_next = helper_switch_tab.bind(null, +1)
285
286 helper_is_visited = (tab) ->
287 return tab.getAttribute('VimFx-visited') or not tab.getAttribute('unread')
288
289 commands.tab_select_most_recent = ({vim, count = 1}) ->
290 {gBrowser} = vim.window
291 tabsSorted =
292 Array.filter(
293 gBrowser.tabs,
294 (tab) -> not tab.closing and helper_is_visited(tab)
295 ).sort((a, b) -> b.lastAccessed - a.lastAccessed)[1..] # Remove current tab.
296 tab = tabsSorted[Math.min(count - 1, tabsSorted.length - 1)]
297 if tab
298 gBrowser.selectedTab = tab
299 else
300 vim.notify(translate('notification.tab_select_most_recent.none'))
301
302 commands.tab_select_oldest_unvisited = ({vim, count = 1}) ->
303 {gBrowser} = vim.window
304 tabsSorted =
305 Array.filter(
306 gBrowser.tabs,
307 (tab) -> not tab.closing and not helper_is_visited(tab)
308 ).sort((a, b) -> a.lastAccessed - b.lastAccessed)
309 tab = tabsSorted[Math.min(count - 1, tabsSorted.length - 1)]
310 if tab
311 gBrowser.selectedTab = tab
312 else
313 vim.notify(translate('notification.tab_select_oldest_unvisited.none'))
314
315 helper_move_tab = (direction, {vim, count = 1}) ->
316 {gBrowser} = vim.window
317 index = absoluteTabIndex(direction * count, gBrowser, {pinnedSeparate: true})
318 utils.nextTick(vim.window, ->
319 gBrowser.moveTabTo(gBrowser.selectedTab, index)
320 )
321
322 commands.tab_move_backward = helper_move_tab.bind(null, -1)
323
324 commands.tab_move_forward = helper_move_tab.bind(null, +1)
325
326 commands.tab_move_to_window = ({vim}) ->
327 {gBrowser} = vim.window
328 gBrowser.replaceTabWithWindow(gBrowser.selectedTab)
329
330 commands.tab_select_first = ({vim, count = 1}) ->
331 utils.nextTick(vim.window, ->
332 vim.window.gBrowser.selectTabAtIndex(count - 1)
333 )
334
335 commands.tab_select_first_non_pinned = ({vim, count = 1}) ->
336 firstNonPinned = vim.window.gBrowser._numPinnedTabs
337 utils.nextTick(vim.window, ->
338 vim.window.gBrowser.selectTabAtIndex(firstNonPinned + count - 1)
339 )
340
341 commands.tab_select_last = ({vim, count = 1}) ->
342 utils.nextTick(vim.window, ->
343 vim.window.gBrowser.selectTabAtIndex(-count)
344 )
345
346 commands.tab_toggle_pinned = ({vim}) ->
347 currentTab = vim.window.gBrowser.selectedTab
348 if currentTab.pinned
349 vim.window.gBrowser.unpinTab(currentTab)
350 else
351 vim.window.gBrowser.pinTab(currentTab)
352
353 commands.tab_close = ({vim, count = 1}) ->
354 {gBrowser} = vim.window
355 return if gBrowser.selectedTab.pinned
356 currentIndex = gBrowser.visibleTabs.indexOf(gBrowser.selectedTab)
357 utils.nextTick(vim.window, ->
358 for tab in gBrowser.visibleTabs[currentIndex...(currentIndex + count)]
359 gBrowser.removeTab(tab)
360 return
361 )
362
363 commands.tab_restore = ({vim, count = 1}) ->
364 utils.nextTick(vim.window, ->
365 for index in [0...count] by 1
366 restoredTab = vim.window.undoCloseTab()
367 if not restoredTab and index == 0
368 vim.notify(translate('notification.tab_restore.none'))
369 break
370 return
371 )
372
373 commands.tab_restore_list = ({vim}) ->
374 {window} = vim
375 fragment = window.RecentlyClosedTabsAndWindowsMenuUtils.getTabsFragment(
376 window, 'menuitem'
377 )
378 if fragment.childElementCount == 0
379 vim.notify(translate('notification.tab_restore.none'))
380 else
381 utils.openPopup(utils.injectTemporaryPopup(window.document, fragment))
382
383 commands.tab_close_to_end = ({vim}) ->
384 {gBrowser} = vim.window
385 gBrowser.removeTabsToTheEndFrom(gBrowser.selectedTab)
386
387 commands.tab_close_other = ({vim}) ->
388 {gBrowser} = vim.window
389 gBrowser.removeAllTabsBut(gBrowser.selectedTab)
390
391
392
393 helper_follow = (name, vim, callback, count = null) ->
394 vim.markPageInteraction()
395 help.removeHelp(vim.window)
396
397 # Enter hints mode immediately, with an empty set of markers. The user might
398 # press keys before the `vim._run` callback is invoked. Those key presses
399 # should be handled in hints mode, not normal mode.
400 initialMarkers = []
401 storage = vim.enterMode('hints', initialMarkers, callback, count,
402 vim.options.hints_sleep)
403
404 vim._run(name, null, ({wrappers, viewport}) ->
405 # The user might have exited hints mode (and perhaps even entered it again)
406 # before this callback is invoked. If so, `storage.markers` has been
407 # cleared, or set to a new value. Only proceed if it is unchanged.
408 return unless storage.markers == initialMarkers
409
410 if wrappers.length > 0
411 {markers, markerMap} = hints.injectHints(vim.window, wrappers, viewport,
412 vim.options)
413 storage.markers = markers
414 storage.markerMap = markerMap
415 else
416 vim.notify(translate('notification.follow.none'))
417 vim.enterMode('normal')
418 )
419
420 helper_follow_clickable = ({inTab, inBackground}, {vim, count = 1}) ->
421 callback = (marker, timesLeft, keyStr) ->
422 {type, elementIndex} = marker.wrapper
423 isLast = (timesLeft == 1)
424 isLink = (type == 'link')
425
426 switch
427 when keyStr.startsWith(vim.options.hints_toggle_in_tab)
428 inTab = not inTab
429 when keyStr.startsWith(vim.options.hints_toggle_in_background)
430 inTab = true
431 inBackground = not inBackground
432 else
433 unless isLast
434 inTab = true
435 inBackground = true
436
437 inTab = false unless isLink
438
439 if type == 'text' or (isLink and not (inTab and inBackground))
440 isLast = true
441
442 vim._focusMarkerElement(elementIndex)
443
444 if inTab
445 utils.nextTick(vim.window, ->
446 utils.openTab(vim.window, marker.wrapper.href, {
447 inBackground
448 relatedToCurrent: true
449 })
450 )
451 else
452 vim._run('click_marker_element', {
453 elementIndex, type
454 preventTargetBlank: vim.options.prevent_target_blank
455 })
456
457 return not isLast
458
459 name = if inTab then 'follow_in_tab' else 'follow'
460 helper_follow(name, vim, callback, count)
461
462 commands.follow =
463 helper_follow_clickable.bind(null, {inTab: false, inBackground: true})
464
465 commands.follow_in_tab =
466 helper_follow_clickable.bind(null, {inTab: true, inBackground: true})
467
468 commands.follow_in_focused_tab =
469 helper_follow_clickable.bind(null, {inTab: true, inBackground: false})
470
471 commands.follow_in_window = ({vim}) ->
472 callback = (marker) ->
473 vim._focusMarkerElement(marker.wrapper.elementIndex)
474 vim.window.openLinkIn(marker.wrapper.href, 'window', {})
475 helper_follow('follow_in_tab', vim, callback)
476
477 commands.follow_multiple = (args) ->
478 args.count = Infinity
479 commands.follow(args)
480
481 commands.follow_copy = ({vim}) ->
482 callback = (marker) ->
483 {elementIndex} = marker.wrapper
484 property = switch marker.wrapper.type
485 when 'link'
486 'href'
487 when 'text'
488 'value'
489 when 'contenteditable'
490 'textContent'
491 vim._run('copy_marker_element', {elementIndex, property})
492 helper_follow('follow_copy', vim, callback)
493
494 commands.follow_focus = ({vim}) ->
495 callback = (marker) ->
496 vim._focusMarkerElement(marker.wrapper.elementIndex, {select: true})
497 return helper_follow('follow_focus', vim, callback)
498
499 commands.click_browser_element = ({vim}) ->
500 markerElements = []
501
502 filter = (element, getElementShape) ->
503 document = element.ownerDocument
504 type = switch
505 when vim._state.scrollableElements.has(element)
506 'scrollable'
507 when utils.isFocusable(element) or
508 (element.onclick and element.localName != 'statuspanel')
509 'clickable'
510 return unless type
511 return unless shape = getElementShape(element)
512 length = markerElements.push(element)
513 return {type, semantic: true, shape, elementIndex: length - 1}
514
515 callback = (marker) ->
516 element = markerElements[marker.wrapper.elementIndex]
517 switch marker.wrapper.type
518 when 'scrollable'
519 utils.focusElement(element, {flag: 'FLAG_BYKEY'})
520 when 'clickable'
521 sequence =
522 if element.localName == 'tab'
523 ['mousedown']
524 else
525 'click-xul'
526 utils.focusElement(element)
527 utils.simulateMouseEvents(element, sequence)
528
529 {wrappers, viewport} =
530 hints.getMarkableElementsAndViewport(vim.window, filter)
531
532 if wrappers.length > 0
533 {markers} = hints.injectHints(vim.window, wrappers, viewport, {
534 hint_chars: vim.options.hint_chars
535 ui: true
536 })
537 vim.enterMode('hints', markers, callback)
538 else
539 vim.notify(translate('notification.follow.none'))
540
541 helper_follow_pattern = (type, {vim}) ->
542 options = {
543 pattern_selector: vim.options.pattern_selector
544 pattern_attrs: vim.options.pattern_attrs
545 patterns: vim.options["#{type}_patterns"]
546 }
547 vim._run('follow_pattern', {type, options})
548
549 commands.follow_previous = helper_follow_pattern.bind(null, 'prev')
550
551 commands.follow_next = helper_follow_pattern.bind(null, 'next')
552
553 commands.focus_text_input = ({vim, count}) ->
554 vim.markPageInteraction()
555 vim._run('focus_text_input', {count})
556
557
558
559 findStorage = {lastSearchString: ''}
560
561 helper_find = ({highlight, linksOnly = false}, {vim}) ->
562 helpSearchInput = help.getSearchInput(vim.window)
563 if helpSearchInput
564 helpSearchInput.select()
565 return
566
567 helper_mark_last_scroll_position(vim)
568 findBar = vim.window.gBrowser.getFindBar()
569
570 mode = if linksOnly then findBar.FIND_LINKS else findBar.FIND_NORMAL
571 findBar.startFind(mode)
572 utils.focusElement(findBar._findField, {select: true})
573
574 return if linksOnly
575 return unless highlightButton = findBar.getElement('highlight')
576 if highlightButton.checked != highlight
577 highlightButton.click()
578
579 commands.find = helper_find.bind(null, {highlight: false})
580
581 commands.find_highlight_all = helper_find.bind(null, {highlight: true})
582
583 commands.find_links_only = helper_find.bind(null, {linksOnly: true})
584
585 helper_find_again = (direction, {vim}) ->
586 findBar = vim.window.gBrowser.getFindBar()
587 if findStorage.lastSearchString.length == 0
588 vim.notify(translate('notification.find_again.none'))
589 return
590 helper_mark_last_scroll_position(vim)
591 findBar._findField.value = findStorage.lastSearchString
592 findBar.onFindAgainCommand(direction)
593 message = findBar._findStatusDesc.textContent
594 vim.notify(message) if message
595
596 commands.find_next = helper_find_again.bind(null, false)
597
598 commands.find_previous = helper_find_again.bind(null, true)
599
600
601
602 commands.window_new = ({vim}) ->
603 vim.window.OpenBrowserWindow()
604
605 commands.window_new_private = ({vim}) ->
606 vim.window.OpenBrowserWindow({private: true})
607
608 commands.enter_mode_ignore = ({vim}) ->
609 vim.enterMode('ignore', {type: 'explicit'})
610
611 # Quote next keypress (pass it through to the page).
612 commands.quote = ({vim, count = 1}) ->
613 vim.enterMode('ignore', {type: 'explicit', count})
614
615 commands.enter_reader_view = ({vim}) ->
616 button = vim.window.document.getElementById('reader-mode-button')
617 if not button?.hidden
618 button.click()
619 else
620 vim.notify(translate('notification.enter_reader_view.none'))
621
622 commands.reload_config_file = ({vim}) ->
623 vim._parent.emit('shutdown')
624 config.load(vim._parent, (status) -> switch status
625 when null
626 vim.notify(translate('notification.reload_config_file.none'))
627 when true
628 vim.notify(translate('notification.reload_config_file.success'))
629 else
630 vim.notify(translate('notification.reload_config_file.failure'))
631 )
632
633 commands.help = ({vim}) ->
634 help.injectHelp(vim.window, vim._parent)
635
636 commands.dev = ({vim}) ->
637 vim.window.DeveloperToolbar.show(true) # `true` to focus.
638
639 commands.esc = ({vim}) ->
640 vim._run('esc')
641 utils.blurActiveBrowserElement(vim)
642 vim.window.DeveloperToolbar.hide()
643 vim.window.gBrowser.getFindBar().close()
644 # TODO: Remove when Tab Groups have been removed.
645 vim.window.TabView?.hide()
646 hints.removeHints(vim.window) # Better safe than sorry.
647
648 unless help.getSearchInput(vim.window)?.getAttribute('focused')
649 help.removeHelp(vim.window)
650
651
652
653 module.exports = {
654 commands
655 findStorage
656 }
Imprint / Impressum