1 utils = require 'utils'
17 constructor: (@window) ->
25 Object.defineProperty(this, 'findStr',
26 get: -> return Vim.findStr
27 set: (value) -> Vim.findStr = value
30 enterHintsMode: (@markers, @cb) ->
33 # TODO: This function should probably remove
34 # hint markers (if they are present) as well
37 @markers = @cb = undefined
39 handleKeyDown: (keyboardEvent, keyStr) ->
40 if @mode == MODE_NORMAL || keyStr == 'Esc'
41 result = maybeCommand(@keys.concat([keyStr]))
42 else if !keyboardEvent.ctrlKey and !keyboardEvent.metaKey
43 if @mode == MODE_HINTS
44 result = utils.getHintChars().search(utils.regexpEscape(keyStr)) > -1
52 handleKeyPress: (keyboardEvent) ->
53 lastKeyStr = if @keys.length > 0 then @keys[@keys.length - 1] else undefined
54 if @mode == MODE_NORMAL or lastKeyStr == 'Esc'
55 if command = findCommand(@keys)
59 else if !keyboardEvent.ctrlKey and !keyboardEvent.metaKey
61 if @mode == MODE_HINTS
62 hintCharHandler(@, lastKeyStr, keyboardEvent.charCode)
67 findCommand = (keys) ->
68 for i in [0...keys.length]
69 seq = keys[i..].join(',')
70 if com = commands[seq]
71 if not isCommandDisabled(seq)
76 maybeCommand = (keys) ->
77 for i in [0...keys.length]
78 sequence = keys[i..].join(',')
79 for seq, com of commands
80 if seq.indexOf(sequence) == 0
81 return not isCommandDisabled(seq)