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