on master help sign in
Return the number of rows to skip after rendering
eb3424cBen Boeckel
src/Graphics/Vty/Span.hs+34−22
@@ -111,7 +111,7 @@ build_spans pic region = do
111 -- The ops builder recursively descends the image and outputs span ops that would
111 -- The ops builder recursively descends the image and outputs span ops that would
112 -- display that image. The number of columns remaining in this row before exceeding the
112 -- display that image. The number of columns remaining in this row before exceeding the
113 -- bounds is also provided. This is used to clip the span ops produced.
113 -- bounds is also provided. This is used to clip the span ops produced.
114− ops_for_row mrow_ops (pic_background pic) region (pic_image pic) 0 0 0 (region_width region)
114+ _ <- ops_for_row mrow_ops (pic_background pic) region (pic_image pic) 0 0 0 (region_width region)
115 -- Fill in any unspecified columns with the background pattern.
115 -- Fill in any unspecified columns with the background pattern.
116 forM_ [0 .. region_height region - 1] $ \row -> do
116 forM_ [0 .. region_height region - 1] $ \row -> do
117 end_x <- readSTArray mrow_ops row >>= return . span_ops_effected_columns
117 end_x <- readSTArray mrow_ops row >>= return . span_ops_effected_columns
@@ -123,39 +123,51 @@ build_spans pic region = do
123
123
124type MRowOps s = STArray s Word SpanOps
124type MRowOps s = STArray s Word SpanOps
125
125
126−ops_for_row :: MRowOps s -> Background -> DisplayRegion -> Image -> Word -> Word -> Word -> Word -> ST s ()
126+ops_for_row :: MRowOps s -> Background -> DisplayRegion -> Image -> Word -> Word -> Word -> Word -> ST s Word
127ops_for_row mrow_ops bg region image skip_row skip_col y remaining_columns
127ops_for_row mrow_ops bg region image skip_row skip_col y remaining_columns
128− | remaining_columns == 0 = return ()
128+ | remaining_columns == 0 = return skip_row
129− | y >= region_height region = return ()
129+ | y >= region_height region = return skip_row
130 | otherwise = case image of
130 | otherwise = case image of
131− EmptyImage -> return ()
131+ EmptyImage -> return skip_row
132 -- The width provided is the number of columns this text span will occupy when displayed.
132 -- The width provided is the number of columns this text span will occupy when displayed.
133 -- if this is greater than the number of remaining columsn the output has to be produced a
133 -- if this is greater than the number of remaining columsn the output has to be produced a
134 -- character at a time.
134 -- character at a time.
135 HorizText a text_str _ _ -> do
135 HorizText a text_str _ _ -> do
136− if y < skip_row
136+ if skip_row > 0
137− then return ()
137+ then return $ skip_row - 1
138+ else do
138− else snoc_text_span a text_str mrow_ops skip_col y remaining_columns
139+ snoc_text_span a text_str mrow_ops skip_col y remaining_columns
140+ return skip_row
139 VertJoin t b _ _ -> do
141 VertJoin t b _ _ -> do
140− ops_for_row mrow_ops bg region t skip_row skip_col y remaining_columns
142+ skip_row' <- ops_for_row mrow_ops bg region t skip_row skip_col y remaining_columns
141− ops_for_row mrow_ops bg region b skip_row skip_col (y + image_height t) remaining_columns
143+ ops_for_row mrow_ops bg region b skip_row' skip_col (y + image_height t - (skip_row - skip_row')) remaining_columns
142 HorizJoin l r _ _ -> do
144 HorizJoin l r _ _ -> do
143− ops_for_row mrow_ops bg region l skip_row skip_col y remaining_columns
145+ skip_row' <- ops_for_row mrow_ops bg region l skip_row skip_col y remaining_columns
144 -- Don't output the right part unless there is at least a single column left after
146 -- Don't output the right part unless there is at least a single column left after
145 -- outputting the left part.
147 -- outputting the left part.
146− if image_width l < remaining_columns
148+ if image_width l > remaining_columns
149+ then return skip_row'
150+ else do
147− then ops_for_row mrow_ops bg region r skip_row skip_col y (remaining_columns - image_width l)
151+ skip_row'' <- ops_for_row mrow_ops bg region r skip_row skip_col y (remaining_columns - image_width l)
148− else return ()
152+ return $ min skip_row' skip_row''
149 BGFill width height -> do
153 BGFill width height -> do
150− let actual_height = if y + height > region_height region
154+ let min_height = if y + height > region_height region
151− then region_height region - y
155+ then region_height region - y
152− else height
156+ else height
157+ min_width = if width > remaining_columns
158+ then remaining_columns
159+ else width
160+ actual_height = if skip_row > min_height
161+ then 0
162+ else min_height - skip_row
153− actual_width = if width > remaining_columns
163+ actual_width = if skip_col > min_width
154− then remaining_columns
164+ then 0
155− else width
165+ else min_width - skip_col
156− -- XXX: Do we need to notify this of skip_rows or skip_cols?
157 forM_ [y .. y + actual_height - 1] $ \y' -> snoc_bg_fill mrow_ops bg actual_width y'
166 forM_ [y .. y + actual_height - 1] $ \y' -> snoc_bg_fill mrow_ops bg actual_width y'
167+ if actual_height > skip_row
168+ then return 0
169+ else return $ skip_row - min_height
158− Translation (dx,dy) i ->
170+ Translation (dx,dy) i -> do
159 if dx < 0
171 if dx < 0
160 -- Translation left
172 -- Translation left
161 -- Extract the delta and add it to skip_col.
173 -- Extract the delta and add it to skip_col.