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 System.IO (Handle)
17import Text.PrettyPrint.ANSI.Leijen
18 ( Doc, (<>), displayS, displayIO, dullcyan
19 , hardline, plain, renderPretty, text
22import qualified Reporting.Helpers as Help
23import qualified Reporting.Region as R
24import qualified Reporting.Render.Code as Code
33 , _highlight :: Maybe R.Region
39report :: Text -> Maybe R.Region -> Text -> Doc -> Report
40report title highlight pre post =
41 Report title highlight (Help.reflowParagraph pre) post
48toJson :: [Json.Pair] -> Report -> (Maybe R.Region, [Json.Pair])
49toJson extraFields (Report title subregion pre post) =
53 , "overview" .= nonAnsiRender pre
54 , "details" .= nonAnsiRender post
57 (subregion, fields ++ extraFields)
64toDoc :: String -> R.Region -> Report -> Text -> Doc
65toDoc location region (Report title highlight preHint postHint) source =
66 messageBar title location
67 <> hardline <> hardline <>
69 <> hardline <> hardline <>
70 Code.render highlight region source
73 <> hardline <> hardline
76messageBar :: Text -> String -> Doc
77messageBar tag location =
80 4 + Text.length tag + 1 + length location
83 "-- " ++ Text.unpack tag
84 ++ " " ++ replicate (max 1 (80 - usedSpace)) '-'
92toHandle :: Handle -> String -> R.Region -> Report -> Text -> IO ()
93toHandle handle location region rprt source =
96 (renderPretty 1 80 (toDoc location region rprt source))
99toString :: String -> R.Region -> Report -> Text -> String
100toString location region rprt source =
101 nonAnsiRender (toDoc location region rprt source)
105-- DOC TO STRING WITH NO ANSI CODES
108nonAnsiRender :: Doc -> String
110 displayS (renderPretty 1 80 (plain doc)) ""
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