Skip to content

Commit

Permalink
Limit to positive scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jan 16, 2017
1 parent 1992c83 commit a7e2b90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 1 addition & 3 deletions rasa-ext-slate/src/Rasa/Ext/Slate/Internal/Render.hs
Expand Up @@ -82,12 +82,10 @@ renderView (width, height) (vw, buf) = appendActiveBar . resize $ textImage
availHeight = if isActive then height - 1
else height

trimText = Y.concat . take availHeight . drop (vw^.scrollPos & negate) . Y.lines'
trimText = Y.concat . take availHeight . drop (vw^.scrollPos) . Y.lines'

resize = V.resize width availHeight
textImage = applyAttrs atts txt
textHeight = V.imageHeight textImage
txt = buf^.text & trimText
scrollAmt = max (-textHeight) (vw^.scrollPos)
atts = buf^.styles & fmap (fmap convertStyle)
isActive = vw ^. active
4 changes: 3 additions & 1 deletion rasa-ext-views/src/Rasa/Ext/Views/Internal/Views.hs
Expand Up @@ -208,4 +208,6 @@ ensureOneActive w = if not $ anyOf traverse _active w

-- | Scroll all active viewports by the given amount.
scrollBy :: Int -> Window -> Window
scrollBy amt = (traverse.filtered (view active).scrollPos) +~ amt
scrollBy amt = traverse.filtered (view active).scrollPos %~ scroll
where
scroll = max 0 . (+ amt)
8 changes: 4 additions & 4 deletions rasa-ext-vim/src/Rasa/Ext/Vim.hs
Expand Up @@ -108,10 +108,10 @@ normal [Keypress 'v' [Ctrl]] = liftAction vSplit
normal [Keypress 'o' [Ctrl]] = liftAction closeInactive
normal [Keypress 'r' [Ctrl]] = liftAction rotate

normal [Keypress 'e' [Ctrl]] = liftAction $ scrollBy (-1) -- Scroll down
normal [Keypress 'd' [Ctrl]] = liftAction $ scrollBy (-7) -- Half-Page down
normal [Keypress 'y' [Ctrl]] = liftAction $ scrollBy 1 -- Scroll up
normal [Keypress 'u' [Ctrl]] = liftAction $ scrollBy 7 -- Half-Page up
normal [Keypress 'e' [Ctrl]] = liftAction $ scrollBy 1 -- Scroll down
normal [Keypress 'd' [Ctrl]] = liftAction $ scrollBy 7 -- Half-Page down
normal [Keypress 'y' [Ctrl]] = liftAction $ scrollBy (-1) -- Scroll up
normal [Keypress 'u' [Ctrl]] = liftAction $ scrollBy (-7) -- Half-Page up

normal [KLeft] = liftAction focusViewLeft
normal [KRight] = liftAction focusViewRight
Expand Down

0 comments on commit a7e2b90

Please sign in to comment.