1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
12import Data.Aeson ((.=))
13import qualified Data.Aeson.Types as Json
14import System.IO (Handle)
15import Text.PrettyPrint.ANSI.Leijen
16 ( Doc, (<>), displayS, displayIO, dullcyan, fillSep, hardline, renderPretty, text
19import qualified Reporting.Region as R
20import qualified Reporting.Render.Code as Code
29 , _highlight :: Maybe R.Region
35report :: String -> Maybe R.Region -> String -> Doc -> Report
36report title highlight pre post =
37 Report title highlight (fillSep (map text (words pre))) post
44toJson :: [Json.Pair] -> Report -> (Maybe R.Region, [Json.Pair])
45toJson extraFields (Report title subregion pre post) =
49 , "overview" .= displayS (renderPretty 1 80 pre) ""
50 , "details" .= displayS (renderPretty 1 80 post) ""
53 (subregion, fields ++ extraFields)
60toDoc :: String -> R.Region -> Report -> String -> Doc
61toDoc location region (Report title highlight preHint postHint) source =
62 messageBar title location
63 <> hardline <> hardline <>
65 <> hardline <> hardline <>
66 Code.render highlight region source
69 <> hardline <> hardline
72messageBar :: String -> String -> Doc
73messageBar tag location =
76 4 + length tag + 1 + length location
79 "-- " ++ tag ++ " " ++ replicate (max 1 (80 - usedSpace)) '-' ++ " " ++ location
86toString :: String -> R.Region -> Report -> String -> String
87toString location region rprt source =
89 (renderPretty 1 80 (toDoc location region rprt source))
93toHandle :: Handle -> String -> R.Region -> Report -> String -> IO ()
94toHandle handle location region rprt source =
97 (renderPretty 1 80 (toDoc location region rprt source))
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