1module SourceSyntax.Location where
4import SourceSyntax.PrettyPrint
5import qualified Text.Parsec.Pos as Parsec
7data SrcPos = Pos { line :: Int, column :: Int }
10data SrcSpan = Span SrcPos SrcPos String | NoSpan String
13data Located e = L SrcSpan e
16none e = L (NoSpan (render $ pretty e)) e
17noneNoDocs = L (NoSpan "")
19at start end e = L (Span (Pos (Parsec.sourceLine start) (Parsec.sourceColumn start))
20 (Pos (Parsec.sourceLine end ) (Parsec.sourceColumn end ))
21 (render $ pretty e)) e
23merge (L s1 _) (L s2 _) e = L (span (render $ pretty e)) e
24 where span = case (s1,s2) of
25 (Span start _ _, Span _ end _) -> Span start end
26 (Span start end _, _) -> Span start end
27 (_, Span start end _) -> Span start end
30mergeOldDocs (L s1 _) (L s2 _) e = L span e
31 where span = case (s1,s2) of
32 (Span start _ d1, Span _ end d2) -> Span start end (d1 ++ "\n\n" ++ d2)
40instance Show SrcPos where
41 show (Pos r c) = show r ++ "," ++ show c
43instance Show SrcSpan where
48 case line start == line end of
49 False -> "between lines " ++ show (line start) ++ " and " ++ show (line end)
50 True -> "on line " ++ show (line end) ++ ", column " ++
51 show (column start) ++ " to " ++ show (column end)
53instance Show e => Show (Located e) where
56instance Pretty a => Pretty (Located a) where
57 pretty (L _ e) = pretty e
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