diff options
| author | Stephen Blott | 2016-04-14 10:35:10 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2016-04-14 10:35:10 +0100 | 
| commit | f9c00d9d56373566c034685d0e4bb99ff3b0367b (patch) | |
| tree | 0cf92a9f1484666294b7a329919e598efac6e5cc | |
| parent | f144c7c9d3f141636ce6a3856db3abf08a4fc063 (diff) | |
| parent | 72ff4204655b8e87f7bdfbe8c9974376fbbc15a6 (diff) | |
| download | vimium-f9c00d9d56373566c034685d0e4bb99ff3b0367b.tar.bz2 | |
Merge pull request #2093 from smblott-github/c-y-c-e-for-visual-mode
Add <c-y> and <c-e> for visual mode.
| -rw-r--r-- | content_scripts/mode_visual.coffee | 8 | ||||
| -rw-r--r-- | content_scripts/scroller.coffee | 4 | ||||
| -rw-r--r-- | lib/handler_stack.coffee | 23 | 
3 files changed, 20 insertions, 15 deletions
| diff --git a/content_scripts/mode_visual.coffee b/content_scripts/mode_visual.coffee index 8c1fb5a4..97ad5ca6 100644 --- a/content_scripts/mode_visual.coffee +++ b/content_scripts/mode_visual.coffee @@ -223,8 +223,12 @@ class VisualMode extends KeyHandlerMode          keyMapping[keys[0]] ?= {}          extend keyMapping[keys[0]], "#{keys[1]}": command: movement -    # Aliases. -    extend keyMapping, "B": keyMapping.b, "W": keyMapping.w +    # Aliases and complex bindings. +    extend keyMapping, +      "B": keyMapping.b +      "W": keyMapping.w +      "<c-e>": command: (count) -> Scroller.scrollBy "y", count * Settings.get("scrollStepSize"), 1, false +      "<c-y>": command: (count) -> Scroller.scrollBy "y", -count * Settings.get("scrollStepSize"), 1, false      super extend options,        name: options.name ? "visual" diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index 6965f706..56b9a6c6 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -232,7 +232,7 @@ Scroller =    # scroll the active element in :direction by :amount * :factor.    # :factor is needed because :amount can take on string values, which scrollBy converts to element dimensions. -  scrollBy: (direction, amount, factor = 1) -> +  scrollBy: (direction, amount, factor = 1, continuous = true) ->      # if this is called before domReady, just use the window scroll function      if (!document.body and amount instanceof Number)        if (direction == "x") @@ -249,7 +249,7 @@ Scroller =      unless CoreScroller.wouldNotInitiateScroll()        element = findScrollableElement activatedElement, direction, amount, factor        elementAmount = factor * getDimension element, direction, amount -      CoreScroller.scroll element, direction, elementAmount +      CoreScroller.scroll element, direction, elementAmount, continuous    scrollTo: (direction, pos) ->      activatedElement ||= (document.body and firstScrollableElement()) or document.body diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index c17be24f..806b707f 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -93,20 +93,21 @@ class HandlerStack      @continueBubbling    alwaysSuppressPropagation: (handler = null) -> -    handler?() -    @suppressPropagation +    if handler?() == @suppressEvent then @suppressEvent else @suppressPropagation    # Debugging.    logResult: (eventNumber, type, event, handler, result) -> -    label = -      switch result -        when @passEventToPage then "passEventToPage" -        when @suppressPropagation then "suppressPropagation" -        when @restartBubbling then "restartBubbling" -        when "skip" then "skip" -        when true then "continue" -    label ||= if result then "continue/truthy" else "suppress" -    console.log "#{eventNumber}", type, handler._name, label +    if event?.type == "keydown" # Tweak this as needed. +      label = +        switch result +          when @passEventToPage then "passEventToPage" +          when @suppressEvent then "suppressEvent" +          when @suppressPropagation then "suppressPropagation" +          when @restartBubbling then "restartBubbling" +          when "skip" then "skip" +          when true then "continue" +      label ||= if result then "continue/truthy" else "suppress" +      console.log "#{eventNumber}", type, handler._name, label    show: ->      console.log "#{@eventNumber}:" | 
