module Graphics.Gnuplot.Terminal.X11 (
   T, cons,
   title, noTitle,
   persist, noPersist,
   ) where

import qualified Graphics.Gnuplot.Private.Terminal as Terminal
import Data.Maybe (catMaybes, )
import Graphics.Gnuplot.Utility (quote, formatBool, )


data T =
   Cons {
      T -> Maybe String
title_ :: Maybe String,
      T -> Maybe Bool
persist_ :: Maybe Bool
   }

cons :: T
cons :: T
cons =
   Cons :: Maybe String -> Maybe Bool -> T
Cons {
      title_ :: Maybe String
title_ = Maybe String
forall a. Maybe a
Nothing,
      persist_ :: Maybe Bool
persist_ = Maybe Bool
forall a. Maybe a
Nothing
   }


title :: String -> T -> T
title :: String -> T -> T
title String
text T
term = T
term{title_ :: Maybe String
title_ = String -> Maybe String
forall a. a -> Maybe a
Just String
text}

noTitle :: T -> T
noTitle :: T -> T
noTitle T
term = T
term{title_ :: Maybe String
title_ = Maybe String
forall a. Maybe a
Nothing}

persist, noPersist :: T -> T
persist :: T -> T
persist   T
term = T
term{persist_ :: Maybe Bool
persist_ = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True}
noPersist :: T -> T
noPersist T
term = T
term{persist_ :: Maybe Bool
persist_ = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False}


instance Terminal.C T where
   canonical :: T -> T
canonical T
term =
      Cons :: [String] -> [String] -> [String] -> Bool -> T
Terminal.Cons {
         precommands :: [String]
Terminal.precommands = [],
         options :: [String]
Terminal.options =
            String
"x11" String -> [String] -> [String]
forall a. a -> [a] -> [a]
:
            [Maybe String] -> [String]
forall a. [Maybe a] -> [a]
catMaybes (
               ((String -> String) -> Maybe String -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> String
quote (Maybe String -> Maybe String) -> Maybe String -> Maybe String
forall a b. (a -> b) -> a -> b
$ T -> Maybe String
title_ T
term) Maybe String -> [Maybe String] -> [Maybe String]
forall a. a -> [a] -> [a]
:
               ((Bool -> String) -> Maybe Bool -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (String -> Bool -> String
formatBool String
"persist") (Maybe Bool -> Maybe String) -> Maybe Bool -> Maybe String
forall a b. (a -> b) -> a -> b
$ T -> Maybe Bool
persist_ T
term) Maybe String -> [Maybe String] -> [Maybe String]
forall a. a -> [a] -> [a]
:
               []),
         commands :: [String]
Terminal.commands = [],
         interactive :: Bool
Terminal.interactive = Bool
True
      }