module Darcs.Patch.FileHunk ( FileHunk(..), IsHunk(..), showFileHunk ) where import Prelude () import Darcs.Prelude import Darcs.Util.Path ( FileName ) import Darcs.Patch.Format ( FileNameFormat ) import Darcs.Patch.Show ( formatFileName ) import Darcs.Util.Printer ( Doc, blueText, text, lineColor, vcat, userchunkPS , prefix, ($$), (<+>), Color(Cyan, Magenta) ) import qualified Data.ByteString as B ( ByteString ) data FileHunk wX wY = FileHunk !FileName !Int [B.ByteString] [B.ByteString] class IsHunk p where isHunk :: p wX wY -> Maybe (FileHunk wX wY) showFileHunk :: FileNameFormat -> FileHunk wX wY -> Doc showFileHunk :: FileNameFormat -> FileHunk wX wY -> Doc showFileHunk x :: FileNameFormat x (FileHunk f :: FileName f line :: Int line old :: [ByteString] old new :: [ByteString] new) = String -> Doc blueText "hunk" Doc -> Doc -> Doc <+> FileNameFormat -> FileName -> Doc formatFileName FileNameFormat x FileName f Doc -> Doc -> Doc <+> String -> Doc text (Int -> String forall a. Show a => a -> String show Int line) Doc -> Doc -> Doc $$ Color -> Doc -> Doc lineColor Color Magenta (String -> Doc -> Doc prefix "-" ([Doc] -> Doc vcat ([Doc] -> Doc) -> [Doc] -> Doc forall a b. (a -> b) -> a -> b $ (ByteString -> Doc) -> [ByteString] -> [Doc] forall a b. (a -> b) -> [a] -> [b] map ByteString -> Doc userchunkPS [ByteString] old)) Doc -> Doc -> Doc $$ Color -> Doc -> Doc lineColor Color Cyan (String -> Doc -> Doc prefix "+" ([Doc] -> Doc vcat ([Doc] -> Doc) -> [Doc] -> Doc forall a b. (a -> b) -> a -> b $ (ByteString -> Doc) -> [ByteString] -> [Doc] forall a b. (a -> b) -> [a] -> [b] map ByteString -> Doc userchunkPS [ByteString] new))