diagrams-pgf 1.4 → 1.4.1
raw patch · 5 files changed
+43/−32 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Backend.PGF.Surface.Surface, Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Monoid.Any)
- Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Backend.PGF.Surface.Surface, System.Texrunner.Online.OnlineTex (Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Monoid.Any))
- Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Monoid.Any)
- Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (System.Texrunner.Online.OnlineTex (Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Monoid.Any))
- Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable [(GHC.Base.String, Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Monoid.Any)]
+ Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Backend.PGF.Surface.Surface, Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Semigroup.Internal.Any)
+ Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Backend.PGF.Surface.Surface, System.Texrunner.Online.OnlineTex (Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Semigroup.Internal.Any))
+ Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Semigroup.Internal.Any)
+ Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable (System.Texrunner.Online.OnlineTex (Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Semigroup.Internal.Any))
+ Diagrams.Backend.PGF.CmdLine: instance Diagrams.Core.Types.TypeableFloat n => Diagrams.Backend.CmdLine.Mainable [(GHC.Base.String, Diagrams.Core.Types.QDiagram Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n Data.Semigroup.Internal.Any)]
+ Diagrams.Backend.PGF.Render: data family Render b (v :: Type -> Type) n :: Type
+ Diagrams.Backend.PGF.Render: instance GHC.Base.Semigroup (Diagrams.Core.Types.Render Diagrams.Backend.PGF.Render.PGF Linear.V2.V2 n)
- Diagrams.Backend.PGF: data OnlineTex a :: * -> *
+ Diagrams.Backend.PGF: data OnlineTex a
- Diagrams.Backend.PGF.CmdLine: mainWith :: (Mainable d, Parseable (MainOpts d)) => d -> IO ()
+ Diagrams.Backend.PGF.CmdLine: mainWith :: Mainable d => d -> IO ()
- Diagrams.Backend.PGF.Hbox: Hbox :: (Transformation V2 n) -> String -> Hbox n
+ Diagrams.Backend.PGF.Hbox: Hbox :: Transformation V2 n -> String -> Hbox n
- Graphics.Rendering.PGF: style :: forall n_alVV. Lens' (RenderState n_alVV) (Style V2 n_alVV)
+ Graphics.Rendering.PGF: style :: forall n_arYY. Lens' (RenderState n_arYY) (Style V2 n_arYY)
Files
- diagrams-pgf.cabal +10/−10
- src/Diagrams/Backend/PGF.hs +7/−4
- src/Diagrams/Backend/PGF/Hbox.hs +6/−5
- src/Diagrams/Backend/PGF/Render.hs +17/−10
- src/Diagrams/Backend/PGF/Surface.hs +3/−3
diagrams-pgf.cabal view
@@ -1,5 +1,5 @@ name: diagrams-pgf-version: 1.4+version: 1.4.1 synopsis: PGF backend for diagrams drawing EDSL. license: BSD3 license-file: LICENSE@@ -10,10 +10,10 @@ stability: Experimental category: Graphics build-type: Simple-cabal-version: >=1.10+cabal-version: >=1.18 extra-source-files: README.md, diagrams/*.svg extra-doc-files: diagrams/*.svg-tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3, GHC == 8.6.1 description: This package provides a modular backend for rendering diagrams created with the diagrams EDSL using the TeX library PGF.@@ -33,22 +33,22 @@ Graphics.Rendering.PGF hs-source-dirs: src build-depends:- base >= 4.4 && < 4.10,+ base >= 4.4 && < 4.13, bytestring >= 0.9 && < 1.1, bytestring-builder < 1.1,- containers >= 0.3 && < 0.6,+ containers >= 0.3 && < 0.7, colour,- diagrams-core >= 1.3 && < 1.5,- diagrams-lib >= 1.3 && < 1.5,+ diagrams-core >= 1.4 && < 1.5,+ diagrams-lib >= 1.4 && < 1.5, directory >= 1.0 && < 1.4, filepath >= 1.2 && < 1.5, hashable >= 1.1 && < 1.3, mtl >= 2.1 && < 3.0,- optparse-applicative >= 0.13 && < 0.14,- process >= 1.0 && < 1.5,+ optparse-applicative >= 0.13 && < 0.15,+ process >= 1.0 && < 1.7, split >= 0.1.2 && < 0.3, texrunner <= 0.0.2,- time >= 1.2 && < 1.7,+ time >= 1.2 && < 1.10, JuicyPixels, vector, zlib
src/Diagrams/Backend/PGF.hs view
@@ -99,7 +99,6 @@ import Data.ByteString.Builder import System.Directory hiding (readable) import System.FilePath-import System.IO import System.Texrunner import System.Texrunner.Online hiding (hbox) @@ -214,7 +213,11 @@ writeTexFile :: (TypeableFloat n, Monoid' m) => FilePath -> Options PGF V2 n -> QDiagram PGF V2 n m -> IO () writeTexFile outFile opts d = do- h <- openFile outFile WriteMode- hPutBuilder h $ renderDia PGF opts d- hClose h+ let bs = toLazyByteString $ renderDia PGF opts d+ LB.writeFile outFile bs+ -- h <- openFile outFile WriteMode+ -- hSetBinaryMode h True+ -- hSetBuffering h (BlockBuffering (Just 80000))+ -- hPutBuilder h $ renderDia PGF opts d+ -- hClose h
src/Diagrams/Backend/PGF/Hbox.hs view
@@ -27,7 +27,7 @@ -- ** Non-Online version -- | These versions bypass 'OnlineTex' by just running a whole tex -- program just to get the size of a single hbox. This is not- -- recommended but because it is slow, but can be convientient if+ -- recommended but because it is slow, but can be convenient if -- you only need one or two hbox sizes. , hboxSurf , hboxSurfIO@@ -37,7 +37,8 @@ ) where -import Data.ByteString.Char8 (pack)+import Data.ByteString.Lazy (toStrict)+import Data.ByteString.Builder (stringUtf8, toLazyByteString) import Data.Monoid import Data.Typeable import System.IO.Unsafe@@ -75,7 +76,7 @@ mempty -- | Hbox with bounding box envelope. Note that each box requires a call to--- Tex. For multiple boxes consider using 'onlineHbox' to get multiple boxes+-- Tex. For multiple boxes consider using 'hboxOnline' to get multiple boxes -- from a single call. (uses unsafePerformIO) hboxSurf :: (TypeableFloat n, Renderable (Hbox n) b) => Surface -> String -> QDiagram b V2 n Any@@ -83,7 +84,7 @@ {-# NOINLINE hboxSurf #-} -- | Hbox with bounding box envelope. Note that each box requires a call to--- Tex. For multiple boxes consider using 'onlineHbox' to get multiple boxes+-- Tex. For multiple boxes consider using 'hboxOnline' to get multiple boxes -- from a single call. hboxSurfIO :: (TypeableFloat n, Renderable (Hbox n) b) => Surface -> String -> IO (QDiagram b V2 n Any)@@ -93,7 +94,7 @@ hboxOnline :: (TypeableFloat n, Renderable (Hbox n) b) => String -> OnlineTex (QDiagram b V2 n Any) hboxOnline txt = do- Box h d w <- Online.hbox (pack txt)+ Box h d w <- Online.hbox (toStrict . toLazyByteString $ stringUtf8 txt) let bb = fromCorners (P $ V2 0 (-d)) (P $ V2 w h)
src/Diagrams/Backend/PGF/Render.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -12,9 +13,9 @@ -- License : BSD-style (see LICENSE) -- Maintainer : diagrams-discuss@googlegroups.com ----- This is an internal module exposeing internals for rendering a+-- This is an internal module exposing internals for rendering a -- diagram. This is for advanced use only. 'Diagrams.Backend.PGF'--- has enought for general use.+-- has enough for general use. -- module Diagrams.Backend.PGF.Render ( PGF (..)@@ -40,18 +41,19 @@ import Data.Tree (Tree (Node)) import Diagrams.Core.Types-import Diagrams.Prelude hiding ((<~))+import Diagrams.Prelude hiding ((<~)) +import Data.Typeable import Diagrams.Backend.PGF.Hbox (Hbox (..)) import Diagrams.Backend.PGF.Surface (Surface) import Diagrams.TwoD.Adjust (adjustDia2D) import Diagrams.TwoD.Path-import Diagrams.TwoD.Text (Text (..), TextAlignment (..), getFontSize,- getFontSlant, getFontWeight)-import Data.Typeable+import Diagrams.TwoD.Text (Text (..), TextAlignment (..),+ getFontSize, getFontSlant,+ getFontWeight) import qualified Graphics.Rendering.PGF as P -import Prelude+import Prelude -- | This data declaration is simply used as a token to distinguish -- this rendering engine.@@ -97,9 +99,14 @@ , _standalone = False } +instance Semigroup (Render PGF V2 n) where+ R ra <> R rb = R $ ra >> rb+ instance Monoid (Render PGF V2 n) where- mempty = R $ return ()- R ra `mappend` R rb = R $ ra >> rb+ mempty = R $ return ()+#if !MIN_VERSION_base(4,11,0)+ mappend = (<>)+#endif -- | Lens onto the surface used to render. surface :: Lens' (Options PGF V2 n) Surface@@ -148,7 +155,7 @@ go (p:ps) = P.scope $ P.path p >> P.clip >> go ps -- | Escapes some common characters in a string. Note that this does not--- mean the string can't create an error, it mearly escapes common+-- mean the string can't create an error; it merely escapes common -- characters. escapeString :: String -> String escapeString = concatMap escapeChar
src/Diagrams/Backend/PGF/Surface.hs view
@@ -53,17 +53,17 @@ import Diagrams.Prelude import Prelude --- | The 'TexFormat' is used to choose the different PGF commands nessesary for+-- | The 'TexFormat' is used to choose the different PGF commands necessary for -- that format. data TexFormat = LaTeX | ConTeXt | PlainTeX deriving (Show, Read, Eq, Typeable)- -- These names are only captialised so Context doesn't conflict with+ -- These names are only capitalised so Context doesn't conflict with -- lens's Context. data Surface = Surface { _texFormat :: TexFormat -- ^ Format for the PGF commands , _command :: String -- ^ System command to be called.- , _arguments :: [String] -- ^ Auguments for command.+ , _arguments :: [String] -- ^ Arguments for command. , _pageSize :: Maybe (V2 Int -> String) -- ^ Command to change page size from dimensions of image. -- (in bp)