8import qualified Reporting.Region as R
12 { highlight :: Maybe R.Region
18simple :: String -> String -> Report
20 Report Nothing pre post
23toString :: String -> String -> R.Region -> Report -> String -> String
24toString tag location region report source =
26 [ messageBar tag location
27 , preHint report ++ "\n\n"
28 , grabRegion (highlight report) region source ++ "\n"
29 , postHint report ++ "\n\n\n"
35messageBar :: String -> String -> String
36messageBar tag location =
37 let usedSpace = 4 + length tag + 1 + length location
40 ++ replicate (max 1 (80 - usedSpace)) '-'
41 ++ " " ++ location ++ "\n\n"
46grabRegion :: Maybe R.Region -> R.Region -> String -> String
47grabRegion maybeSubRegion (R.Region start end) source =
49 (R.Position startLine startColumn) = start
50 (R.Position endLine endColumn) = end
54 |> drop (startLine - 1)
55 |> take (endLine - startLine + 1)
59 error "something has gone badly wrong with reporting source locations"
64 w = length (show (n + 1))
66 replicate (startColumn - 1) ' '
67 ++ replicate (max 1 (endColumn - startColumn)) '^'
69 addLineNumber Nothing w
74 , number (n+1) underline
80 replicate (startColumn - 1) ' '
81 ++ drop (startColumn - 1) firstLine
84 take (endColumn) (last rest)
86 focusedRelevantLines =
87 filteredFirstLine : init rest ++ [filteredLastLine]
90 length (show (endLine + 1))
94 (addLineNumber maybeSubRegion lineNumbersWidth)
95 [startLine - 1 .. endLine + 1]
96 ("" : focusedRelevantLines ++ [""])
101addLineNumber :: Maybe R.Region -> Int -> Int -> String -> String
102addLineNumber maybeSubRegion width n line =
105 if n < 0 then " " else show n
107 spacer (R.Region start end) =
108 if R.line start <= n && n <= R.line end
112 replicate (width - length number) ' ' ++ number
113 ++ "|" ++ maybe " " spacer maybeSubRegion
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