{-# LANGUAGE BangPatterns #-}
module Client.Image (clientPicture) where
import Client.Image.Layout
import Client.State
import Control.Lens
import Graphics.Vty (Background (..), Cursor (..),
Picture (..))
import Graphics.Vty.Image
clientPicture :: ClientState -> (Picture, ClientState)
clientPicture st = (pic, st')
where
(pos, img, st') = clientImage st
pic = Picture
{ picCursor = AbsoluteCursor pos (view clientHeight st - 1)
, picBackground = ClearBackground
, picLayers = [img]
}
clientImage ::
ClientState ->
(Int, Image, ClientState)
clientImage st = (pos, img, st')
where
!st' = set clientTextBoxOffset nextOffset
$ over clientScroll (max 0 . subtract overscroll) st
(overscroll, pos, nextOffset, img) = drawLayout st