 
-# This prevents unmapped printable characters from being passed through to underlying page.
+# This prevents printable characters from being passed through to underlying page.  It should, however, allow
+# through chrome keyboard shortcuts.  It's a backstop for all of the modes following.
 class SuppressPrintable extends Mode
   constructor: (options) ->
 
     handler = (event) =>
       if KeyboardUtils.isPrintable event
         if event.type == "keydown"
-          DomUtils. suppressPropagation
+          DomUtils.suppressPropagation
           @stopBubblingAndTrue
         else
           @suppressEvent
       else
         @stopBubblingAndTrue
 
+    # This is pushed onto the handler stack before calling super().  Therefore, it ends up underneath (or
+    # after) all of the other handlers associated with the mode.
     @suppressPrintableHandlerId = handlerStack.push
       _name: "movement/suppress-printable"
       keydown: handler

        @alwaysContinueBubbling =>
          unless event.metaKey or event.ctrlKey or event.altKey
            keyChar = String.fromCharCode event.charCode
            @countPrefix = if isNumberKey keyChar then @countPrefix + keyChar else ""

  countPrefixTimes: (func) ->
    countPrefix = if 0 < @countPrefix.length then parseInt @countPrefix else 1
    @countPrefix = ""
    func() for [0...countPrefix]

# This implements movement commands with count prefixes (using MaintainCount) for visual and edit modes.
class Movement extends MaintainCount
  movements:
    h: "backward character"
    l: "forward character"
    k: "backward line"
    j: "forward line"
    b: "backward word"
    e: "forward word"

  constructor: (options) ->
    @alterMethod = options.alterMethod || "extend"
    super options

    super options
    @onExit => handlerStack.remove @suppressPrintableHandlerId

# This watches keyboard events and maintains @countPrefix as count and other keys are pressed.
class MaintainCount extends SuppressPrintable
  constructor: (options) ->
    @countPrefix = ""
    super options

    @push
      _name: "movement/maintain-count"
