1 utils = require 'utils'
2 { mode_hints } = require 'mode-hints/mode-hints'
3 { updateToolbarButton } = require 'button'
5 , searchForMatchingCommand } = require 'commands'
10 onEnter: (vim, storage, args) ->
12 storage.commands ?= {}
14 onLeave: (vim, storage, args) ->
15 storage.keys.length = 0
17 onInput: (vim, storage, keyStr, event) ->
18 storage.keys.push(keyStr)
20 runCommand = (command) ->
21 commandStorage = storage.commands[command.name] ?= {}
22 command.func(vim, commandStorage, event)
24 { match, exact, command, index } = searchForMatchingCommand(storage.keys)
27 storage.keys = storage.keys[index..]
30 return keyStr != 'Esc'
32 storage.keys.length = 0
37 return unless rootWindow = utils.getRootWindow(vim.window)
38 updateToolbarButton(rootWindow, {insertMode: true})
40 return unless rootWindow = utils.getRootWindow(vim.window)
41 updateToolbarButton(rootWindow, {insertMode: false})
42 utils.blurActiveElement(vim.window)
43 onInput: (vim, storage, keyStr) ->
45 modes['hints'] = mode_hints