Skip to content

Commit

Permalink
screened 2025-01-03 15:04:30+00:00
Browse files Browse the repository at this point in the history
  • Loading branch information
bfrk committed Jan 3, 2025
1 parent 8bc7124 commit d1a9763
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 48 deletions.
6 changes: 2 additions & 4 deletions src/Darcs/Patch/Summary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import Darcs.Util.Printer
, ($$)
, (<+>)
, empty
, minus
, plus
, text
, vcat
)
Expand Down Expand Up @@ -171,8 +169,8 @@ summChunkToLine machineReadable (SummChunk detail c) =
| otherwise = text t <+> x <+> text "duplicate"
--
ad 0 = empty
ad a = plus <> text (show a)
ad a = text "+" <> text (show a)
rm 0 = empty
rm a = minus <> text (show a)
rm a = text "-" <> text (show a)
rp 0 = empty
rp a = text "r" <> text (show a)
10 changes: 5 additions & 5 deletions src/Darcs/UI/Commands/Send.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import Darcs.UI.Completion ( prefArgs )
import Darcs.UI.Commands.Util ( getUniqueDPatchName )
import Darcs.Util.Printer
( Doc, formatWords, vsep, text, ($$), (<+>), putDoc, putDocLn
, quoted, renderPS, sentence, vcat
, quoted, renderPS, vcat
)
import Darcs.Util.English ( englishNum, Noun(..) )
import Darcs.Util.Exception ( catchall )
Expand Down Expand Up @@ -598,7 +598,7 @@ selectionIsNull :: Doc
selectionIsNull = text "You don't want to send any patches, and that's fine with me!"

emailBackedUp :: String -> Doc
emailBackedUp mf = sentence $ "Email body left in" <+> text mf <> "."
emailBackedUp mf = "Email body left in" <+> text mf <> "."

promptCharSetWarning :: String -> String
promptCharSetWarning msg = "Warning: " ++ msg ++ " Send anyway?"
Expand All @@ -613,8 +613,8 @@ aborted :: Doc
aborted = "Aborted."

success :: String -> String -> Doc
success to cc = sentence $
"Successfully sent patch bundle to:" <+> text to <+> copies cc
success to cc =
"Successfully sent patch bundle to:" <+> text to <+> copies cc <> "."
where
copies "" = ""
copies x = "and cc'ed" <+> text x
Expand All @@ -623,7 +623,7 @@ postingPatch :: String -> Doc
postingPatch url = "Posting patch to" <+> text url

wroteBundle :: FilePathLike a => a -> Doc
wroteBundle a = sentence $ "Wrote patch to" <+> text (toFilePath a)
wroteBundle a = "Wrote patch to" <+> text (toFilePath a) <> "."

savedButNotSent :: String -> Doc
savedButNotSent to =
Expand Down
4 changes: 2 additions & 2 deletions src/Darcs/UI/Commands/Unrecord.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import qualified Darcs.UI.SelectChanges as S ( PatchSelectionOptions(..) )
import Darcs.Util.English ( presentParticiple )
import Darcs.Util.Lock ( writeDocBinFile )
import Darcs.Util.Path ( AbsolutePath, toFilePath, useAbsoluteOrStd )
import Darcs.Util.Printer ( Doc, formatWords, putDoc, sentence, text, ($+$), (<+>) )
import Darcs.Util.Printer ( Doc, formatWords, putDoc, text, ($+$), (<+>) )
import Darcs.Util.Progress ( debugMessage )
import Darcs.Util.Prompt ( promptYorn )
import Darcs.Util.SignalHandler ( catchInterrupt, withSignalsBlocked )
Expand Down Expand Up @@ -304,7 +304,7 @@ savetoBundle opts removed@(x :>: _) orig = do
when exists $
fail $ "Directory or file named '" ++ (show outname) ++ "' already exists."
useAbsoluteOrStd writeDocBinFile putDoc outname bundle
putInfo opts $ sentence $
putInfo opts $ (<> ".") $
useAbsoluteOrStd
(("Saved patch bundle" <+>) . text . toFilePath)
(text "stdout")
Expand Down
8 changes: 5 additions & 3 deletions src/Darcs/UI/External.hs
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,14 @@ getViewer = Just `fmap` (getEnv "DARCS_PAGER" `catchall` getEnv "PAGER")
return Nothing

pipeDocToPager :: String -> [String] -> Printers -> Doc -> IO ExitCode

pipeDocToPager "" _ pr inp = do
hPutDocLnWith pr stdout inp
return ExitSuccess

pipeDocToPager c args pr inp = pipeDocInternal (PipeToOther pr) c args inp
pipeDocToPager c args pr inp =
-- Evaluate pr with the current stdout, not the pipe's write end,
-- so we get colored output with less. Note that we pass it -R so
-- that it doesn't escape color codes.
pipeDocInternal (PipeToOther (const (pr stdout))) c args inp

-- | Given two shell commands as arguments, execute the former. The
-- latter is then executed if the former failed because the executable
Expand Down
35 changes: 1 addition & 34 deletions src/Darcs/Util/Printer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ module Darcs.Util.Printer
-- * 'Doc' type and structural combinators
Doc(Doc,unDoc)
, empty, (<>), (<?>), (<+>), ($$), ($+$), vcat, vsep, hcat, hsep
, minus, newline, plus, space, backslash, lparen, rparen
, parens, sentence
-- * Constructing 'Doc's
, newline
, text
, hiddenText
, invisibleText
Expand Down Expand Up @@ -79,42 +78,10 @@ spaceP = Both " " (BC.singleton ' ')
newlineP :: Printable
newlineP = S "\n"

-- | A 'Doc' representing a space (\" \")
space :: Doc
space = unsafeBoth " " (BC.singleton ' ')

-- | A 'Doc' representing a newline
newline :: Doc
newline = unsafeChar '\n'

-- | A 'Doc' representing a \"-\"
minus :: Doc
minus = unsafeBoth "-" (BC.singleton '-')

-- | A 'Doc' representing a \"+\"
plus :: Doc
plus = unsafeBoth "+" (BC.singleton '+')

-- | A 'Doc' representing a \"\\\"
backslash :: Doc
backslash = unsafeBoth "\\" (BC.singleton '\\')

-- | A 'Doc' that represents @\"(\"@
lparen :: Doc
lparen = unsafeBoth "(" (BC.singleton '(')

-- | A 'Doc' that represents @\")\"@
rparen :: Doc
rparen = unsafeBoth ")" (BC.singleton ')')

-- | prop> parens d = lparen <> d <> rparen
parens :: Doc -> Doc
parens d = lparen <> d <> rparen

-- | Turn a 'Doc' into a sentence. This appends a ".".
sentence :: Doc -> Doc
sentence = (<> text ".")

-- | Format a list of 'FilePath's as quoted text. It deliberately refuses to
-- use English.andClauses but rather separates the quoted strings only with a
-- space, because this makes it usable for copy and paste e.g. as arguments to
Expand Down

0 comments on commit d1a9763

Please sign in to comment.