@@ -1,11 +1,9 @@
1−{-# LANGUAGE MultiWayIf #-}
1+-- Copyright Corey O'Connor
22{-# LANGUAGE TemplateHaskell #-}
3−-- Copyright 2009-2010 Corey O'Connor
43{-# LANGUAGE BangPatterns #-}
54{-# LANGUAGE ExistentialQuantification #-}
65{-# LANGUAGE NamedFieldPuns #-}
76{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE ExistentialQuantification #-}
97{-# LANGUAGE ScopedTypeVariables #-}
108-- The ops to define the content for an output region.
119module Graphics.Vty.Span
@@ -281,6 +279,19 @@ add_maybe_clipped BGFill {output_width, output_height} = do
281279 let output_width' = min (output_width - s.^skip_columns) s.^remaining_columns
282280 output_height' = min (output_height - s.^skip_rows ) s.^remaining_rows
283281 add_unclipped (BGFill output_width' output_height')
282+add_maybe_clipped CropRight {cropped_image, output_width} = do
283+ remaining_columns .= output_width
284+ add_maybe_clipped cropped_image
285+add_maybe_clipped CropLeft {cropped_image, left_skip} = do
286+ skip_columns += left_skip
287+ add_maybe_clipped cropped_image
288+add_maybe_clipped CropBottom {cropped_image, output_height} = do
289+ remaining_rows .= output_height
290+ add_maybe_clipped cropped_image
291+add_maybe_clipped CropTop {cropped_image, top_skip} = do
292+ skip_rows += top_skip
293+ add_maybe_clipped cropped_image
294+
284295add_maybe_clipped_join name skip remaining offset i0_dim i0 i1 size = do
285296 state <- get
286297 when (state^.remaining == 0) $ fail $ name ++ " with remaining == 0"
@@ -328,34 +339,6 @@ add_unclipped_text txt = do
328339 used_display_columns = wcswidth $ TL.unpack txt
329340 use row_offset >>= snoc_op op
330341
331−-- | Add a background fill of the given column width to the row display operations.
332−--
333−-- This has a fast path for background characters that are a single column and a single byte.
334−-- Otherwise this has to compute the width of the background character and replicate a sequence of
335−-- bytes to fill in the required width.
336−snoc_bg_fill :: MRowOps s -> Background -> Int -> Int -> ST s ()
337−snoc_bg_fill _row_ops _bg 0 _row
338− = return ()
339−snoc_bg_fill mrow_ops (Background c back_attr) fill_length row
340− = do
341− snoc_op mrow_ops row $ AttributeChange back_attr
342− -- By all likelyhood the background character will be an ASCII character. Which is a single
343− -- byte in utf8. Optimize for this special case.
344− utf8_bs <- if c <= (toEnum 255 :: Char)
345− then
346− let !(c_byte :: Word8) = BInt.c2w c
347− in unsafeIOToST $ do
348− BInt.create fill_length
349− $ \ptr -> mapM_ (\i -> pokeByteOff ptr i c_byte)
350− [0 .. (fill_length - 1)]
351− else
352− let !(c_bytes :: [Word8]) = encode [c]
353− in unsafeIOToST $ do
354− BInt.create (fill_length * length c_bytes)
355− $ \ptr -> mapM_ (\(i,b) -> pokeByteOff ptr i b)
356− $ zip [0 .. (fill_length - 1)] (cycle c_bytes)
357− snoc_op mrow_ops row $ TextSpan fill_length fill_length (UTF8.fromRep utf8_bs)
358−
359342-- | snocs the operation to the operations for the given row.
360343snoc_op :: SpanOp -> Int -> BlitM s ()
361344snoc_op !op !row = do