{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE ViewPatterns #-}
module Darcs.Patch.Prim.V1.Show
( showHunk )
where
import Prelude ()
import Darcs.Prelude
import Darcs.Util.ByteString ( fromPS2Hex )
import qualified Data.ByteString as B (ByteString, length, take, drop)
import qualified Data.ByteString.Char8 as BC (head)
import Darcs.Patch.Apply ( ApplyState )
import Darcs.Patch.FileHunk ( FileHunk(..), showFileHunk )
import Darcs.Patch.Format ( FileNameFormat )
import Darcs.Patch.Show ( formatFileName )
import Darcs.Patch.Permutations ()
import Darcs.Patch.Prim.Class ( PrimShow(..) )
import Darcs.Patch.Prim.V1.Core
( Prim(..), FilePatchType(..), DirPatchType(..) )
import Darcs.Patch.Prim.V1.Details ()
import Darcs.Patch.Viewing ( showContextHunk )
import Darcs.Patch.Witnesses.Show ( Show1(..), Show2(..), ShowDict(..) )
import Darcs.Util.Path ( FileName )
import Darcs.Util.Printer ( Doc, vcat,
text, userchunk, invisibleText, invisiblePS, blueText,
($$), (<+>)
)
import Darcs.Util.Show ( appPrec, BSWrapper(..) )
import Darcs.Util.Tree ( Tree )
instance Show (Prim wX wY) where
showsPrec :: Int -> Prim wX wY -> ShowS
showsPrec d :: Int
d (Move fn1 :: FileName
fn1 fn2 :: FileName
fn2) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "Move " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> FileName -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) FileName
fn1 ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> FileName -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) FileName
fn2
showsPrec d :: Int
d (DP fn :: FileName
fn dp :: DirPatchType wX wY
dp) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "DP " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> FileName -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) FileName
fn ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> DirPatchType wX wY -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) DirPatchType wX wY
dp
showsPrec d :: Int
d (FP fn :: FileName
fn fp :: FilePatchType wX wY
fp) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "FP " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> FileName -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) FileName
fn ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> FilePatchType wX wY -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) FilePatchType wX wY
fp
showsPrec d :: Int
d (ChangePref p :: String
p f :: String
f t :: String
t) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "ChangePref " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) String
p ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) String
f ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) String
t
instance Show2 Prim where
showDict2 :: ShowDict (Prim wX wY)
showDict2 = ShowDict (Prim wX wY)
forall a. Show a => ShowDict a
ShowDictClass
instance Show1 (Prim wX) where
showDict1 :: ShowDict (Prim wX wX)
showDict1 = ShowDict (Prim wX wX)
forall a. Show a => ShowDict a
ShowDictClass
instance Show (FilePatchType wX wY) where
showsPrec :: Int -> FilePatchType wX wY -> ShowS
showsPrec _ RmFile = String -> ShowS
showString "RmFile"
showsPrec _ AddFile = String -> ShowS
showString "AddFile"
showsPrec d :: Int
d (Hunk line :: Int
line old :: [ByteString]
old new :: [ByteString]
new) | (ByteString -> Bool) -> [ByteString] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
==1) (Int -> Bool) -> (ByteString -> Int) -> ByteString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
B.length) [ByteString]
old Bool -> Bool -> Bool
&& (ByteString -> Bool) -> [ByteString] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
==1) (Int -> Bool) -> (ByteString -> Int) -> ByteString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
B.length) [ByteString]
new
= Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "Hunk " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) Int
line ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[ByteString] -> ShowS
showsPrecC [ByteString]
old ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[ByteString] -> ShowS
showsPrecC [ByteString]
new
where showsPrecC :: [ByteString] -> ShowS
showsPrecC [] = String -> ShowS
showString "[]"
showsPrecC ss :: [ByteString]
ss = Bool -> ShowS -> ShowS
showParen Bool
True (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "packStringLetters " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) ((ByteString -> Char) -> [ByteString] -> String
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> Char
BC.head [ByteString]
ss)
showsPrec d :: Int
d (Hunk line :: Int
line old :: [ByteString]
old new :: [ByteString]
new) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "Hunk " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) Int
line ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> [BSWrapper] -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) ((ByteString -> BSWrapper) -> [ByteString] -> [BSWrapper]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> BSWrapper
BSWrapper [ByteString]
old) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> [BSWrapper] -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) ((ByteString -> BSWrapper) -> [ByteString] -> [BSWrapper]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> BSWrapper
BSWrapper [ByteString]
new)
showsPrec d :: Int
d (TokReplace t :: String
t old :: String
old new :: String
new) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "TokReplace " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) String
t ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) String
old ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) String
new
showsPrec d :: Int
d (Binary old :: ByteString
old new :: ByteString
new) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString "Binary " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> BSWrapper -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) (ByteString -> BSWrapper
BSWrapper ByteString
old) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Int -> BSWrapper -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec (Int
appPrec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) (ByteString -> BSWrapper
BSWrapper ByteString
new)
instance Show (DirPatchType wX wY) where
showsPrec :: Int -> DirPatchType wX wY -> ShowS
showsPrec _ RmDir = String -> ShowS
showString "RmDir"
showsPrec _ AddDir = String -> ShowS
showString "AddDir"
instance ApplyState Prim ~ Tree => PrimShow Prim where
showPrim :: FileNameFormat -> Prim wA wB -> Doc
showPrim fmt :: FileNameFormat
fmt (FP f :: FileName
f AddFile) = FileNameFormat -> FileName -> Doc
showAddFile FileNameFormat
fmt FileName
f
showPrim fmt :: FileNameFormat
fmt (FP f :: FileName
f RmFile) = FileNameFormat -> FileName -> Doc
showRmFile FileNameFormat
fmt FileName
f
showPrim fmt :: FileNameFormat
fmt (FP f :: FileName
f (Hunk line :: Int
line old :: [ByteString]
old new :: [ByteString]
new)) = FileNameFormat
-> FileName -> Int -> [ByteString] -> [ByteString] -> Doc
showHunk FileNameFormat
fmt FileName
f Int
line [ByteString]
old [ByteString]
new
showPrim fmt :: FileNameFormat
fmt (FP f :: FileName
f (TokReplace t :: String
t old :: String
old new :: String
new)) = FileNameFormat -> FileName -> String -> String -> String -> Doc
showTok FileNameFormat
fmt FileName
f String
t String
old String
new
showPrim fmt :: FileNameFormat
fmt (FP f :: FileName
f (Binary old :: ByteString
old new :: ByteString
new)) = FileNameFormat -> FileName -> ByteString -> ByteString -> Doc
showBinary FileNameFormat
fmt FileName
f ByteString
old ByteString
new
showPrim fmt :: FileNameFormat
fmt (DP d :: FileName
d AddDir) = FileNameFormat -> FileName -> Doc
showAddDir FileNameFormat
fmt FileName
d
showPrim fmt :: FileNameFormat
fmt (DP d :: FileName
d RmDir) = FileNameFormat -> FileName -> Doc
showRmDir FileNameFormat
fmt FileName
d
showPrim fmt :: FileNameFormat
fmt (Move f :: FileName
f f' :: FileName
f') = FileNameFormat -> FileName -> FileName -> Doc
showMove FileNameFormat
fmt FileName
f FileName
f'
showPrim _ (ChangePref p :: String
p f :: String
f t :: String
t) = String -> String -> String -> Doc
showChangePref String
p String
f String
t
showPrimCtx :: FileNameFormat -> Prim wA wB -> m Doc
showPrimCtx fmt :: FileNameFormat
fmt (FP f :: FileName
f (Hunk line :: Int
line old :: [ByteString]
old new :: [ByteString]
new)) = FileNameFormat -> FileHunk Any Any -> m Doc
forall (m :: * -> *) wX wY.
ApplyMonad Tree m =>
FileNameFormat -> FileHunk wX wY -> m Doc
showContextHunk FileNameFormat
fmt (FileName -> Int -> [ByteString] -> [ByteString] -> FileHunk Any Any
forall wX wY.
FileName -> Int -> [ByteString] -> [ByteString] -> FileHunk wX wY
FileHunk FileName
f Int
line [ByteString]
old [ByteString]
new)
showPrimCtx fmt :: FileNameFormat
fmt p :: Prim wA wB
p = Doc -> m Doc
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc -> m Doc) -> Doc -> m Doc
forall a b. (a -> b) -> a -> b
$ FileNameFormat -> Prim wA wB -> Doc
forall (prim :: * -> * -> *) wA wB.
PrimShow prim =>
FileNameFormat -> prim wA wB -> Doc
showPrim FileNameFormat
fmt Prim wA wB
p
showAddFile :: FileNameFormat -> FileName -> Doc
showAddFile :: FileNameFormat -> FileName -> Doc
showAddFile fmt :: FileNameFormat
fmt f :: FileName
f = String -> Doc
blueText "addfile" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
f
showRmFile :: FileNameFormat -> FileName -> Doc
showRmFile :: FileNameFormat -> FileName -> Doc
showRmFile fmt :: FileNameFormat
fmt f :: FileName
f = String -> Doc
blueText "rmfile" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
f
showMove :: FileNameFormat -> FileName -> FileName -> Doc
showMove :: FileNameFormat -> FileName -> FileName -> Doc
showMove fmt :: FileNameFormat
fmt d :: FileName
d d' :: FileName
d' = String -> Doc
blueText "move" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
d Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
d'
showChangePref :: String -> String -> String -> Doc
showChangePref :: String -> String -> String -> Doc
showChangePref p :: String
p f :: String
f t :: String
t = String -> Doc
blueText "changepref" Doc -> Doc -> Doc
<+> String -> Doc
text String
p
Doc -> Doc -> Doc
$$ String -> Doc
userchunk String
f
Doc -> Doc -> Doc
$$ String -> Doc
userchunk String
t
showAddDir :: FileNameFormat -> FileName -> Doc
showAddDir :: FileNameFormat -> FileName -> Doc
showAddDir fmt :: FileNameFormat
fmt d :: FileName
d = String -> Doc
blueText "adddir" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
d
showRmDir :: FileNameFormat -> FileName -> Doc
showRmDir :: FileNameFormat -> FileName -> Doc
showRmDir fmt :: FileNameFormat
fmt d :: FileName
d = String -> Doc
blueText "rmdir" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
d
showHunk :: FileNameFormat -> FileName -> Int -> [B.ByteString] -> [B.ByteString] -> Doc
showHunk :: FileNameFormat
-> FileName -> Int -> [ByteString] -> [ByteString] -> Doc
showHunk fmt :: FileNameFormat
fmt f :: FileName
f line :: Int
line old :: [ByteString]
old new :: [ByteString]
new = FileNameFormat -> FileHunk Any Any -> Doc
forall wX wY. FileNameFormat -> FileHunk wX wY -> Doc
showFileHunk FileNameFormat
fmt (FileName -> Int -> [ByteString] -> [ByteString] -> FileHunk Any Any
forall wX wY.
FileName -> Int -> [ByteString] -> [ByteString] -> FileHunk wX wY
FileHunk FileName
f Int
line [ByteString]
old [ByteString]
new)
showTok :: FileNameFormat -> FileName -> String -> String -> String -> Doc
showTok :: FileNameFormat -> FileName -> String -> String -> String -> Doc
showTok fmt :: FileNameFormat
fmt f :: FileName
f t :: String
t o :: String
o n :: String
n = String -> Doc
blueText "replace" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
f
Doc -> Doc -> Doc
<+> String -> Doc
text "[" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> String -> Doc
userchunk String
t Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> String -> Doc
text "]"
Doc -> Doc -> Doc
<+> String -> Doc
userchunk String
o
Doc -> Doc -> Doc
<+> String -> Doc
userchunk String
n
showBinary :: FileNameFormat -> FileName -> B.ByteString -> B.ByteString -> Doc
showBinary :: FileNameFormat -> FileName -> ByteString -> ByteString -> Doc
showBinary fmt :: FileNameFormat
fmt f :: FileName
f o :: ByteString
o n :: ByteString
n =
String -> Doc
blueText "binary" Doc -> Doc -> Doc
<+> FileNameFormat -> FileName -> Doc
formatFileName FileNameFormat
fmt FileName
f
Doc -> Doc -> Doc
$$ String -> Doc
invisibleText "oldhex"
Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat ((ByteString -> Doc) -> [ByteString] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> Doc
makeprintable ([ByteString] -> [Doc]) -> [ByteString] -> [Doc]
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> [ByteString]
breakEvery 78 (ByteString -> [ByteString]) -> ByteString -> [ByteString]
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
fromPS2Hex ByteString
o)
Doc -> Doc -> Doc
$$ String -> Doc
invisibleText "newhex"
Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat ((ByteString -> Doc) -> [ByteString] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> Doc
makeprintable ([ByteString] -> [Doc]) -> [ByteString] -> [Doc]
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> [ByteString]
breakEvery 78 (ByteString -> [ByteString]) -> ByteString -> [ByteString]
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
fromPS2Hex ByteString
n)
where makeprintable :: ByteString -> Doc
makeprintable ps :: ByteString
ps = String -> Doc
invisibleText "*" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> ByteString -> Doc
invisiblePS ByteString
ps
breakEvery :: Int -> B.ByteString -> [B.ByteString]
breakEvery :: Int -> ByteString -> [ByteString]
breakEvery n :: Int
n ps :: ByteString
ps | ByteString -> Int
B.length ByteString
ps Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
n = [ByteString
ps]
| Bool
otherwise = Int -> ByteString -> ByteString
B.take Int
n ByteString
ps ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: Int -> ByteString -> [ByteString]
breakEvery Int
n (Int -> ByteString -> ByteString
B.drop Int
n ByteString
ps)