diff options
| author | Stephen Blott | 2015-01-11 10:20:54 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-01-11 10:26:16 +0000 | 
| commit | 355bb5fb2a06b4465a354350e2fa78ab5d53cb0b (patch) | |
| tree | c0d6d3e6557c18257b777613b289a6f5ac17668a | |
| parent | e8f10007f1528808f72be6fac829cc55309527f2 (diff) | |
| download | vimium-355bb5fb2a06b4465a354350e2fa78ab5d53cb0b.tar.bz2 | |
Modes; rework debugging support.
| -rw-r--r-- | content_scripts/mode.coffee | 26 | ||||
| -rw-r--r-- | content_scripts/mode_find.coffee | 5 | ||||
| -rw-r--r-- | lib/handler_stack.coffee | 9 | 
3 files changed, 15 insertions, 25 deletions
| diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 6e40089e..61e51b1c 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -63,7 +63,7 @@ class Mode      @count = ++count      @id = "#{@name}-#{@count}" -    @logger "activate:", @id if @debug +    @log "activate:", @id if @debug      @push        keydown: @options.keydown || null @@ -126,7 +126,7 @@ class Mode      Mode.updateBadge() if @badge      Mode.modes.push @ -    @log() if @debug +    @logStack() if @debug      # handlerStack.debugOn()      # End of Mode constructor. @@ -144,7 +144,7 @@ class Mode    exit: ->      if @modeIsActive -      @logger "deactivate:", @id if @debug +      @log "deactivate:", @id if @debug        handler() for handler in @exitHandlers        handlerStack.remove handlerId for handlerId in @handlers        Mode.modes = Mode.modes.filter (mode) => mode != @ @@ -191,23 +191,20 @@ class Mode        # flickering in some cases.        Mode.badgeSuppressor.runSuppresed =>          if singletons[key] -          @logger "singleton:", "deactivating #{singletons[key].id}" if @debug +          @log "singleton:", "deactivating #{singletons[key].id}" if @debug            singletons[key].exit()        singletons[key] = @        @onExit => delete singletons[key] if singletons[key] == @    # Debugging routines. -  log: -> -    if Mode.modes.length == 0 -      @logger "It looks like debugging is not enabled in modes.coffee." -    else -      @logger "active modes (top to bottom), current: #{@id}" -      for mode in Mode.modes[..].reverse() -        @logger " ",  mode.id +  logStack: -> +    @log "active modes (top to bottom):" +    for mode in Mode.modes[..].reverse() +      @log " ",  mode.id -  logger: (args...) -> -    handlerStack.log args... +  log: (args...) -> +    console.log args...  # BadgeMode is a pseudo mode for triggering badge updates on focus changes and state updates. It sits at the  # bottom of the handler stack, and so it receives state changes *after* all other modes, and can override the @@ -245,7 +242,8 @@ new class KeySuppressor extends Mode        keypress: (event) => @handle event        keyup: (event) => @handle event -  handle: (event) -> if event.vimium_suppress_event then @suppressEvent else @continueBubbling +  handle: (event) -> +    if event.vimium_suppress_event then @suppressEvent else @continueBubbling  root = exports ? window  root.Mode = Mode diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 91ae4507..30f136e9 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -4,10 +4,9 @@  # special considerations apply.  We implement three special cases:  #   1. Prevent keyboard events from dropping us unintentionally into insert mode. This is achieved by  #      inheriting from InsertModeBlocker. -#   2. Prevent all printable keyboard events on the active element from propagating.  This is achieved by setting the +#   2. Prevent all printable keypress events on the active element from propagating.  This is achieved by setting the  #      suppressPrintableEvents option.  There's some controversy as to whether this is the right thing to do. -#      See discussion in #1415. This implements Option 2 from there, although Option 3 would be a reasonable -#      alternative. +#      See discussion in #1415. This implements Option 2 from there.  #   3. If the very-next keystroke is Escape, then drop immediately into insert mode.  #  class PostFindMode extends InsertModeBlocker diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index b4cacf74..d671fb3a 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -82,9 +82,6 @@ class HandlerStack      false    # Debugging. -  debugOn: -> @debug = true -  debugOff: -> @debug = false -    logResult: (type, event, handler, result) ->      # FIXME(smblott).  Badge updating is too noisy, so we filter it out.  However, we do need to look at how      # many badge update events are happening.  It seems to be more than necessary. @@ -96,11 +93,7 @@ class HandlerStack          when @restartBubbling then "rebubble"          when true then "continue"      label ||= if result then "continue/truthy" else "suppress" -    @log @eventNumber, type, handler._name, label - -  log: (args...) -> -    line = args.join " " -    console.log line +    console.log "#{@eventNumber}", type, handler._name, label  root.HandlerStack = HandlerStack  root.handlerStack = new HandlerStack() | 
