mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-12 12:23:21 +03:00
Rename lookupViewportR to unsafeLookupViewport, move to Brick.Widgets.Core
This commit is contained in:
parent
902c87d19b
commit
7308e3ed08
@ -44,7 +44,6 @@ module Brick.Types
|
||||
-- ** Rendering results
|
||||
, Result(..)
|
||||
, lookupAttrName
|
||||
, lookupViewportR
|
||||
|
||||
-- ** Rendering result lenses
|
||||
, imageL
|
||||
@ -188,8 +187,3 @@ lookupAttrName :: AttrName -> RenderM Attr
|
||||
lookupAttrName n = do
|
||||
c <- getContext
|
||||
return $ attrMapLookup n (c^.ctxAttrMapL)
|
||||
|
||||
-- | Given a name, obtain the viewport for that name by consulting
|
||||
-- the viewport map in the rendering monad.
|
||||
lookupViewportR :: Name -> RenderM (Maybe Viewport)
|
||||
lookupViewportR name = lift $ gets (M.lookup name . (^.viewportMapL))
|
||||
|
@ -55,6 +55,7 @@ module Brick.Widgets.Core
|
||||
, viewport
|
||||
, visible
|
||||
, visibleRegion
|
||||
, unsafeLookupViewport
|
||||
|
||||
-- ** Adding offsets to cursor positions and visibility requests
|
||||
, addResultOffset
|
||||
@ -629,6 +630,18 @@ viewport vpname typ p =
|
||||
$ padRight Max
|
||||
$ Widget Fixed Fixed $ return $ translated & visibilityRequestsL .~ mempty
|
||||
|
||||
-- | Given a name, obtain the viewport for that name by consulting the
|
||||
-- viewport map in the rendering monad. NOTE! Some care must be taken
|
||||
-- when calling this function, since it only returns useful values
|
||||
-- after the viewport in question has been rendered. If you call this
|
||||
-- function during rendering before a viewport has been rendered, you
|
||||
-- may get nothing or you may get a stale version of the viewport. This
|
||||
-- is because viewports are updated during rendering and the one you are
|
||||
-- interested in may not have been rendered yet. So if you want to use
|
||||
-- this, be sure you know what you are doing.
|
||||
unsafeLookupViewport :: Name -> RenderM (Maybe Viewport)
|
||||
unsafeLookupViewport name = lift $ gets (M.lookup name . (^.viewportMapL))
|
||||
|
||||
scrollTo :: ViewportType -> ScrollRequest -> V.Image -> Viewport -> Viewport
|
||||
scrollTo Both _ _ _ = error "BUG: called scrollTo on viewport type 'Both'"
|
||||
scrollTo Vertical req img vp = vp & vpTop .~ newVStart
|
||||
|
Loading…
Reference in New Issue
Block a user