packages feed

gnuplot 0.5.4.2 → 0.5.5

raw patch · 13 files changed

+153/−13 lines, 13 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Graphics.Gnuplot.Value.Atom: instance Graphics.Gnuplot.Value.Atom.C Data.Time.Clock.UTC.UTCTime
- Graphics.Gnuplot.Value.Tuple: instance Graphics.Gnuplot.Value.Tuple.C Data.Time.Clock.UTC.UTCTime
+ Graphics.Gnuplot.Encoding: cp1250 :: T
+ Graphics.Gnuplot.Encoding: cp1251 :: T
+ Graphics.Gnuplot.Encoding: cp1254 :: T
+ Graphics.Gnuplot.Encoding: cp437 :: T
+ Graphics.Gnuplot.Encoding: cp850 :: T
+ Graphics.Gnuplot.Encoding: cp852 :: T
+ Graphics.Gnuplot.Encoding: cp950 :: T
+ Graphics.Gnuplot.Encoding: data T
+ Graphics.Gnuplot.Encoding: deflt :: T
+ Graphics.Gnuplot.Encoding: iso_8859_1 :: T
+ Graphics.Gnuplot.Encoding: iso_8859_15 :: T
+ Graphics.Gnuplot.Encoding: iso_8859_2 :: T
+ Graphics.Gnuplot.Encoding: iso_8859_9 :: T
+ Graphics.Gnuplot.Encoding: koi8r :: T
+ Graphics.Gnuplot.Encoding: koi8u :: T
+ Graphics.Gnuplot.Encoding: locale :: T
+ Graphics.Gnuplot.Encoding: sjis :: T
+ Graphics.Gnuplot.Encoding: utf8 :: T
+ Graphics.Gnuplot.Terminal.PNG: encoding :: T -> T -> T
+ Graphics.Gnuplot.Terminal.PostScript: encoding :: T -> T -> T
+ Graphics.Gnuplot.Terminal.SVG: encoding :: T -> T -> T
+ Graphics.Gnuplot.Value.Atom: instance Graphics.Gnuplot.Value.Atom.C Data.Time.Clock.Internal.UTCTime.UTCTime
+ Graphics.Gnuplot.Value.Tuple: instance Graphics.Gnuplot.Value.Tuple.C Data.Time.Clock.Internal.UTCTime.UTCTime
- Graphics.Gnuplot.Value.Atom: class C a where options = OptionSet [] [] []
+ Graphics.Gnuplot.Value.Atom: class C a
- Graphics.Gnuplot.Value.Tuple: class C a where columnCount = ColumnCount 1
+ Graphics.Gnuplot.Value.Tuple: class C a

Files

+ Changes.md view
@@ -0,0 +1,7 @@+# Change log for the `gnuplot` Haskell binding++## 0.5.5:++ * `Gnuplot.Utility.quote` bugfix:+   Do not escape printable non-ASCII characters+   because gnuplot has no universal escaping support for Unicode codepoints.
gnuplot.cabal view
@@ -1,5 +1,5 @@ Name:             gnuplot-Version:          0.5.4.2+Version:          0.5.5 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -41,6 +41,7 @@ Build-Type:        Simple Extra-Source-Files:   Makefile+  Changes.md   execute/tmp/Graphics/Gnuplot/Execute.hs   execute/pipe/Graphics/Gnuplot/Execute.hs   execute/shell/Graphics/Gnuplot/Execute.hs@@ -50,7 +51,7 @@   data/runtime.data  Source-Repository this-  Tag:         0.5.4.2+  Tag:         0.5.5   Type:        darcs   Location:    http://code.haskell.org/gnuplot/ @@ -113,6 +114,7 @@     Graphics.Gnuplot.Terminal.SVG     Graphics.Gnuplot.Terminal.WXT     Graphics.Gnuplot.Terminal.X11+    Graphics.Gnuplot.Encoding     Graphics.Gnuplot.Frame     Graphics.Gnuplot.Frame.Option     Graphics.Gnuplot.Frame.OptionSet@@ -144,6 +146,7 @@     Graphics.Gnuplot.Private.Graph3DType     Graphics.Gnuplot.Private.GraphEmpty     Graphics.Gnuplot.Private.Terminal+    Graphics.Gnuplot.Private.Encoding     Graphics.Gnuplot.Private.Display     Graphics.Gnuplot.Private.File     Graphics.Gnuplot.Private.Command
+ src/Graphics/Gnuplot/Encoding.hs view
@@ -0,0 +1,53 @@+{- |+Support for special characters++Gnuplot has no universal Unicode escaping mechanism,+you can only work with encodings.+However, not all terminals support all encodings,+not all terminals even support utf-8.+Some terminals seem to support only one encoding.+E.g. WX seems to support only UTF-8,+X11 seems to support only Latin-1.+Postscript, SVG, PNG seem to support both UTF-8 and Latin-1.++The @gnuplot@ Haskell bindings+always write using the system-wide default encoding.+Thus it is better not to set an encoding other than 'locale' explicitly.+However, if you write the files yourself in a certain encoding+you should use the @encoding@ option of the according terminal.+-}+module Graphics.Gnuplot.Encoding (+   T,+   locale, deflt,+   iso_8859_1, iso_8859_15, iso_8859_2, iso_8859_9,+   koi8r, koi8u,+   cp437, cp850, cp852, cp950, cp1250, cp1251, cp1254,+   sjis, utf8,+   ) where++import Graphics.Gnuplot.Private.Encoding (T(Cons))+++locale, deflt,+   iso_8859_1, iso_8859_15, iso_8859_2, iso_8859_9,+   koi8r, koi8u,+   cp437, cp850, cp852, cp950, cp1250, cp1251, cp1254,+   sjis, utf8 :: T++locale      = Cons "locale"+deflt       = Cons "default"+iso_8859_1  = Cons "iso_8859_1"+iso_8859_15 = Cons "iso_8859_15"+iso_8859_2  = Cons "iso_8859_2"+iso_8859_9  = Cons "iso_8859_9"+koi8r       = Cons "koi8r"+koi8u       = Cons "koi8u"+cp437       = Cons "cp437"+cp850       = Cons "cp850"+cp852       = Cons "cp852"+cp950       = Cons "cp950"+cp1250      = Cons "cp1250"+cp1251      = Cons "cp1251"+cp1254      = Cons "cp1254"+sjis        = Cons "sjis"+utf8        = Cons "utf8"
+ src/Graphics/Gnuplot/Private/Encoding.hs view
@@ -0,0 +1,11 @@+module Graphics.Gnuplot.Private.Encoding where++import Graphics.Gnuplot.Utility (listFromMaybeWith)++newtype T = Cons String++format :: T -> String+format (Cons enc) = "set encoding " ++ enc++formatMaybe :: Maybe T -> [String]+formatMaybe = listFromMaybeWith format
src/Graphics/Gnuplot/Private/Plot.hs view
@@ -23,7 +23,7 @@ import qualified System.FilePath as Path import System.FilePath (FilePath, (</>), ) -import Prelude (Functor, fmap, String, show, Int, succ, writeFile, undefined, )+import Prelude (Functor, fmap, String, show, Int, succ, writeFile, )   {- |
src/Graphics/Gnuplot/Private/Terminal.hs view
@@ -2,6 +2,7 @@  data T =    Cons {+      precommands :: [String],       options :: [String],       commands :: [String],       interactive :: Bool@@ -11,7 +12,8 @@    canonical :: terminal -> T  format :: T -> [String]-format (Cons opts cmds _ia) =+format (Cons pre opts cmds _ia) =+   pre ++    if null opts      then cmds      else (unwords $ "set" : "terminal" : opts) : cmds
src/Graphics/Gnuplot/Terminal/Default.hs view
@@ -14,6 +14,7 @@ instance Terminal.C T where    canonical _term =       Terminal.Cons {+         Terminal.precommands = [],          Terminal.options = [],          Terminal.commands = [],          Terminal.interactive = True  -- Always true? I don't know.
src/Graphics/Gnuplot/Terminal/PNG.hs view
@@ -1,5 +1,6 @@ module Graphics.Gnuplot.Terminal.PNG (    T, cons,+   encoding,    transparent, noTransparent,    interlace, noInterlace,    trueColor, noTrueColor,@@ -7,6 +8,7 @@    ) where  import qualified Graphics.Gnuplot.Private.Terminal as Terminal+import qualified Graphics.Gnuplot.Private.Encoding as Encoding import Data.Maybe (catMaybes, ) import Graphics.Gnuplot.Utility (quote, formatBool, ) @@ -14,6 +16,7 @@ data T =    Cons {       filename_ :: FilePath,+      encoding_ :: Maybe Encoding.T,       transparent_ :: Maybe Bool,       interlace_ :: Maybe Bool,       trueColor_ :: Maybe Bool,@@ -24,6 +27,7 @@ cons path =    Cons {       filename_ = path,+      encoding_ = Nothing,       transparent_ = Nothing,       interlace_ = Nothing,       trueColor_ = Nothing,@@ -31,6 +35,13 @@    }  +{- |+Setting the encoding to anything different+from 'Graphics.Gnuplot.Encoding.locale'+makes only sense if you write your gnuplot files manually using this encoding.+-}+encoding :: Encoding.T -> T -> T+encoding enc term = term{encoding_ = Just enc}  transparent, noTransparent :: T -> T transparent   term = term{transparent_ = Just True}@@ -77,6 +88,7 @@ instance Terminal.C T where    canonical term =       Terminal.Cons {+         Terminal.precommands = Encoding.formatMaybe $ encoding_ term,          Terminal.options =             "png" :             catMaybes (
src/Graphics/Gnuplot/Terminal/PostScript.hs view
@@ -1,18 +1,21 @@ module Graphics.Gnuplot.Terminal.PostScript (    T, cons,+   encoding,    landscape, portrait, eps,    color, monochrome,    font, embedFont,    ) where  import qualified Graphics.Gnuplot.Private.Terminal as Terminal-import Graphics.Gnuplot.Utility (quote, )-import Data.Maybe (maybeToList, )+import qualified Graphics.Gnuplot.Private.Encoding as Encoding+import Graphics.Gnuplot.Utility (listFromMaybeWith, quote, )+import Data.Foldable (foldMap, )   data T =    Cons {       filename_ :: FilePath,+      encoding_ :: Maybe Encoding.T,       mode_ :: Maybe Mode,       color_ :: Maybe Bool,       embedFont_ :: [FilePath],@@ -23,6 +26,7 @@ cons path =    Cons {       filename_ = path,+      encoding_ = Nothing,       mode_ = Nothing,       color_ = Nothing,       embedFont_ = [],@@ -30,6 +34,14 @@    }  +{- |+Setting the encoding to anything different+from 'Graphics.Gnuplot.Encoding.locale'+makes only sense if you write your gnuplot files manually using this encoding.+-}+encoding :: Encoding.T -> T -> T+encoding enc term = term{encoding_ = Just enc}+ landscape :: T -> T landscape = setMode Landscape @@ -83,12 +95,13 @@ instance Terminal.C T where    canonical term =       Terminal.Cons {+         Terminal.precommands = Encoding.formatMaybe $ encoding_ term,          Terminal.options =             "postscript" :-            (maybeToList $ fmap formatMode $ mode_ term) ++-            (maybeToList $ fmap (\b -> if b then "color" else "monochrome") $ color_ term) +++            (listFromMaybeWith formatMode $ mode_ term) +++            (listFromMaybeWith (\b -> if b then "color" else "monochrome") $ color_ term) ++             (concatMap (\path -> "fontfile" : quote path : []) $ embedFont_ term) ++-            (maybe [] (\(name,size) -> "font" : quote name : show size : []) $ font_ term) +++            (foldMap (\(name,size) -> "font" : quote name : show size : []) $ font_ term) ++             [],          Terminal.commands =             ["set output " ++ (quote $ filename_ term)],
src/Graphics/Gnuplot/Terminal/SVG.hs view
@@ -1,22 +1,33 @@ module Graphics.Gnuplot.Terminal.SVG (    T, cons,+   encoding,    ) where  import qualified Graphics.Gnuplot.Private.Terminal as Terminal+import qualified Graphics.Gnuplot.Private.Encoding as Encoding import Graphics.Gnuplot.Utility (quote, )   data T =    Cons {-      filename_ :: FilePath+      filename_ :: FilePath,+      encoding_ :: Maybe Encoding.T    }  cons :: FilePath -> T cons path =    Cons {-      filename_ = path+      filename_ = path,+      encoding_ = Nothing    } +{- |+Setting the encoding to anything different+from 'Graphics.Gnuplot.Encoding.locale'+makes only sense if you write your gnuplot files manually using this encoding.+-}+encoding :: Encoding.T -> T -> T+encoding enc term = term{encoding_ = Just enc}   -- private functions@@ -24,6 +35,7 @@ instance Terminal.C T where    canonical term =       Terminal.Cons {+         Terminal.precommands = Encoding.formatMaybe $ encoding_ term,          Terminal.options =             "svg" :             [],
src/Graphics/Gnuplot/Terminal/WXT.hs view
@@ -41,6 +41,7 @@ instance Terminal.C T where    canonical term =       Terminal.Cons {+         Terminal.precommands = [],          Terminal.options =             "wxt" :             catMaybes (
src/Graphics/Gnuplot/Terminal/X11.hs view
@@ -37,6 +37,7 @@ instance Terminal.C T where    canonical term =       Terminal.Cons {+         Terminal.precommands = [],          Terminal.options =             "x11" :             catMaybes (
src/Graphics/Gnuplot/Utility.hs view
@@ -1,5 +1,8 @@ module Graphics.Gnuplot.Utility where +import Text.Printf (printf, )++import qualified Data.Char as Char import Data.List (intersperse, )  @@ -22,9 +25,27 @@ semiColonConcat = concat . intersperse "; "  -quote :: String -> String-quote = show+{-+In former versions this was simply 'show'.+However, Haskell formats non-ASCII characters with decimal backslash sequences+whereas gnuplot expects octal ones.+gnuplot does also not accept bigger octal numbers.+The current version writes non-ASCII printable characters+with the system default encoding.+-}+quote, _quote :: String -> String+quote str = '"' : foldr (++) "\"" (map escapeChar str)+_quote str = '"' : concatMap escapeChar str ++ "\"" +escapeChar :: Char -> String+escapeChar c =+   case c of+      '"'  -> "\\\""+      '\\' -> "\\\\"+      '\t' -> "\\t"+      '\n' -> "\\n"+      _ -> if Char.isPrint c then [c] else printf "\\%o" $ Char.ord c+ assembleCells :: [[ShowS]] -> String assembleCells ps =    foldr ($) ""@@ -34,6 +55,9 @@             [showString "\n"])          ps) ++listFromMaybeWith :: (a -> b) -> Maybe a -> [b]+listFromMaybeWith f = maybe [] ((:[]) . f)  formatBool :: String -> Bool -> String formatBool name b =