8import qualified Reporting.Region as R
13 , highlight :: Maybe R.Region
19simple :: String -> String -> String -> Report
20simple title pre post =
21 Report title Nothing pre post
24toString :: String -> R.Region -> Report -> String -> String
25toString location region report source =
27 [ messageBar (title report) location
28 , preHint report ++ "\n\n"
29 , grabRegion (highlight report) region source ++ "\n"
30 , postHint report ++ "\n\n\n"
36messageBar :: String -> String -> String
37messageBar tag location =
38 let usedSpace = 4 + length tag + 1 + length location
41 ++ replicate (max 1 (80 - usedSpace)) '-'
42 ++ " " ++ location ++ "\n\n"
47grabRegion :: Maybe R.Region -> R.Region -> String -> String
48grabRegion maybeSubRegion (R.Region start end) source =
50 (R.Position startLine startColumn) = start
51 (R.Position endLine endColumn) = end
55 |> drop (startLine - 1)
56 |> take (endLine - startLine + 1)
63 singleLineRegion startLine sourceLine $
64 case maybeSubRegion of
66 (0, startColumn, endColumn, length sourceLine)
68 Just (R.Region s e) ->
69 (startColumn, R.column s, R.column e, endColumn)
74 replicate (startColumn - 1) ' '
75 ++ drop (startColumn - 1) firstLine
78 take (endColumn) (last rest)
80 focusedRelevantLines =
81 filteredFirstLine : init rest ++ [filteredLastLine]
84 length (show (endLine + 1))
88 (addLineNumber maybeSubRegion lineNumbersWidth)
89 [startLine - 1 .. endLine + 1]
90 ("" : focusedRelevantLines ++ [""])
95addLineNumber :: Maybe R.Region -> Int -> Int -> String -> String
96addLineNumber maybeSubRegion width n line =
99 if n < 0 then " " else show n
101 spacer (R.Region start end) =
102 if R.line start <= n && n <= R.line end
106 replicate (width - length number) ' ' ++ number
107 ++ "|" ++ maybe " " spacer maybeSubRegion
111singleLineRegion :: Int -> String -> (Int, Int, Int, Int) -> String
112singleLineRegion lineNum sourceLine (start, innerStart, innerEnd, end) =
114 w = length (show (lineNum + 1))
117 addLineNumber Nothing w
120 replicate (innerStart - 1) ' '
121 ++ replicate (max 1 (innerEnd - innerStart)) '^'
126 |> take (end - start + 1)
127 |> (++) (replicate (start - 1) ' ')
130 [ number (lineNum-1) ""
131 , number lineNum trimmedSourceLine
132 , number (lineNum+1) underline
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