1 utils = require 'utils'
2 { mode_hints } = require 'mode-hints/mode-hints'
3 { updateToolbarButton } = require 'button'
4 { searchForMatchingCommand
6 , isReturnCommandKey } = require 'commands'
11 onEnter: (vim, storage, args) ->
13 storage.commands ?= {}
15 onLeave: (vim, storage, args) ->
16 storage.keys.length = 0
18 onInput: (vim, storage, keyStr, event) ->
19 storage.keys.push(keyStr)
21 { match, exact, command } = searchForMatchingCommand(storage.keys)
25 commandStorage = storage.commands[command.name] ?= {}
26 command.func(vim, commandStorage, event)
27 storage.keys.length = 0
30 storage.keys.length = 0
34 return unless rootWindow = utils.getRootWindow(vim.window)
35 updateToolbarButton(rootWindow, {insertMode: true})
37 return unless rootWindow = utils.getRootWindow(vim.window)
38 updateToolbarButton(rootWindow, {insertMode: false})
39 utils.blurActiveElement(vim.window)
40 onInput: (vim, storage, keyStr) ->
41 if isEscCommandKey(keyStr)
42 vim.enterMode('normal')
47 if findBar = utils.getRootWindow(vim.window)?.gBrowser.getFindBar()
49 findBar._findField.focus()
50 findBar._findField.select()
52 if findBar = utils.getRootWindow(vim.window)?.gBrowser.getFindBar()
54 onInput: (vim, storage, keyStr) ->
55 if isEscCommandKey(keyStr) or isReturnCommandKey(keyStr) > -1
56 vim.enterMode('normal')
59 modes['hints'] = mode_hints