mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-16 03:16:20 +00:00
ihaskell-graphviz: use SVG and enable by default in IHaskell
This commit is contained in:
parent
198a54485d
commit
e8934f5d61
@ -14,7 +14,7 @@
|
||||
-- @ dot "digraph { l -> o; o -> v; v -> e; h -> a ; a -> s; s -> k ; k -> e ; e -> l ; l -> l}" @
|
||||
module IHaskell.Display.Graphviz (
|
||||
dot
|
||||
, Graphviz
|
||||
, Graphviz(..)
|
||||
) where
|
||||
|
||||
import qualified Data.ByteString.Char8 as Char
|
||||
@ -37,23 +37,19 @@ dot = Dot
|
||||
|
||||
instance IHaskellDisplay Graphviz where
|
||||
display fig = do
|
||||
pngDisp <- graphDataPNG fig
|
||||
return $ Display [pngDisp]
|
||||
svgDisp <- graphDataSVG fig
|
||||
return $ Display [svgDisp]
|
||||
|
||||
name = "ihaskell-graphviz."
|
||||
|
||||
-- Width and height
|
||||
w = 300
|
||||
h = 300
|
||||
|
||||
graphDataPNG :: Graphviz -> IO DisplayData
|
||||
graphDataPNG (Dot dotBody) = do
|
||||
graphDataSVG :: Graphviz -> IO DisplayData
|
||||
graphDataSVG (Dot dotBody) = do
|
||||
switchToTmpDir
|
||||
|
||||
let fname = name ++ "png"
|
||||
let fname = name ++ "svg"
|
||||
-- Write the image.
|
||||
ret <- readProcess "dot" ["-Tpng", "-o", fname] dotBody
|
||||
ret <- readProcess "dot" ["-Tsvg", "-o", fname] dotBody
|
||||
|
||||
-- Force strictness on readProcess, read file, and convert to base64.
|
||||
imgData <- seq (length ret) $ Char.readFile fname
|
||||
return $ png w h $ base64 imgData
|
||||
-- Force strictness on readProcess, read file, and output as SVG
|
||||
imgData <- seq (length ret) $ readFile fname
|
||||
return $ svg imgData
|
||||
|
@ -171,7 +171,7 @@ defaultKernelState :: KernelState
|
||||
defaultKernelState = KernelState
|
||||
{ getExecutionCounter = 1
|
||||
, getLintStatus = LintOn
|
||||
, useSvg = False
|
||||
, useSvg = True
|
||||
, useShowErrors = False
|
||||
, useShowTypes = False
|
||||
, usePager = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user