1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
12import Data.Aeson ((.=))
13import qualified Data.Aeson.Types as Json
14import qualified Data.Text as Text
15import Data.Text (Text)
16import Text.PrettyPrint.ANSI.Leijen (Doc, (<>), displayS, dullcyan, hardline, plain, renderPretty, text)
18import qualified Reporting.Helpers as Help
19import qualified Reporting.Region as R
20import qualified Reporting.Render.Code as Code
30 , _highlight :: Maybe R.Region
36report :: Text -> Maybe R.Region -> Text -> Doc -> Report
37report title highlight pre post =
38 Report title highlight (Help.reflowParagraph pre) post
41reportDoc :: Text -> Maybe R.Region -> [Doc] -> Doc -> Report
42reportDoc title highlight pre post =
43 Report title highlight (Help.hsep pre) post
50toJson :: [Json.Pair] -> Report -> (Maybe R.Region, [Json.Pair])
51toJson extraFields (Report title subregion pre post) =
55 , "overview" .= nonAnsiRender pre
56 , "details" .= nonAnsiRender post
59 (subregion, fields ++ extraFields)
62nonAnsiRender :: Doc -> String
64 displayS (renderPretty 1 80 (plain doc)) ""
71toDoc :: String -> R.Region -> Report -> Text -> Doc
72toDoc location region (Report title highlight preHint postHint) source =
73 messageBar title location
74 <> hardline <> hardline <>
76 <> hardline <> hardline <>
77 Code.render highlight region source
80 <> hardline <> hardline
83messageBar :: Text -> String -> Doc
84messageBar tag location =
87 4 + Text.length tag + 1 + length location
90 "-- " ++ Text.unpack tag
91 ++ " " ++ replicate (max 1 (80 - usedSpace)) '-'
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list