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
17 , hardline, plain, renderPretty, text
20import qualified Reporting.Region as R
21import qualified Reporting.Render.Code as Code
30 , _highlight :: Maybe R.Region
36report :: String -> Maybe R.Region -> String -> Doc -> Report
37report title highlight pre post =
38 Report title highlight (fillSep (map text (words pre))) post
45toJson :: [Json.Pair] -> Report -> (Maybe R.Region, [Json.Pair])
46toJson extraFields (Report title subregion pre post) =
50 , "overview" .= nonAnsiRender pre
51 , "details" .= nonAnsiRender post
54 (subregion, fields ++ extraFields)
61toDoc :: String -> R.Region -> Report -> String -> Doc
62toDoc location region (Report title highlight preHint postHint) source =
63 messageBar title location
64 <> hardline <> hardline <>
66 <> hardline <> hardline <>
67 Code.render highlight region source
70 <> hardline <> hardline
73messageBar :: String -> String -> Doc
74messageBar tag location =
77 4 + length tag + 1 + length location
80 "-- " ++ tag ++ " " ++ replicate (max 1 (80 - usedSpace)) '-' ++ " " ++ location
87toHandle :: Handle -> String -> R.Region -> Report -> String -> IO ()
88toHandle handle location region rprt source =
91 (renderPretty 1 80 (toDoc location region rprt source))
94toString :: String -> R.Region -> Report -> String -> String
95toString location region rprt source =
96 nonAnsiRender (toDoc location region rprt source)
100-- DOC TO STRING WITH NO ANSI CODES
103nonAnsiRender :: Doc -> String
105 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