1{-# LANGUAGE FlexibleInstances #-}
2module AST.PrettyPrint where
4import Control.Monad.Trans.Error
5import Text.PrettyPrint as P
6import qualified AST.Helpers as Help
13instance Pretty Doc where
17instance Pretty String where
21renderPretty :: (Pretty a) => a -> String
26commaCat :: [Doc] -> Doc
28 cat (punctuate comma docs)
31commaSep :: [Doc] -> Doc
33 sep (punctuate comma docs)
36parensIf :: Bool -> Doc -> Doc
38 if bool then parens doc else doc
41variable :: String -> Doc
43 if Help.isOp x then parens (text x) else text x
46eightyCharLines :: Int -> String -> String
47eightyCharLines indent message = answer
49 (answer,_,_) = foldl step (spaces, indent-1, "") chunks
51 chunks = map (\w -> (w, length w)) (words message)
52 spaces = replicate indent ' '
53 step (sentence, slen, space) (word, wlen)
54 | slen + wlen > 79 = (sentence ++ "\n" ++ spaces ++ word, indent + wlen, " ")
55 | otherwise = (sentence ++ space ++ word, slen + wlen + length space, " ")
58instance Error Doc where
63instance ErrorList Doc where
64 listMsg str = [ P.text str ]
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