1{-# LANGUAGE FlexibleInstances #-}
2module SourceSyntax.PrettyPrint where
4import Text.PrettyPrint as P
5import qualified SourceSyntax.Helpers as Help
10instance Pretty Doc where
13instance Pretty String where
16renderPretty :: (Pretty a) => a -> String
17renderPretty e = render (pretty e)
19commaCat docs = cat (punctuate comma docs)
20commaSep docs = sep (punctuate comma docs)
22parensIf :: Bool -> Doc -> Doc
23parensIf bool doc = if bool then parens doc else doc
25variable :: String -> Doc
27 if Help.isOp x then parens (text x)
30reprime :: String -> String
31reprime = map (\c -> if c == '$' then '\'' else c)
33eightyCharLines :: Int -> String -> String
34eightyCharLines indent message = answer
36 (answer,_,_) = foldl step (spaces, indent-1, "") chunks
38 chunks = map (\w -> (w, length w)) (words message)
39 spaces = replicate indent ' '
40 step (sentence, slen, space) (word, wlen)
41 | slen + wlen > 79 = (sentence ++ "\n" ++ spaces ++ word, indent + wlen, " ")
42 | otherwise = (sentence ++ space ++ word, slen + wlen + length space, " ")
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