{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Vte.Enums
    ( 
    catchRegexError                         ,
    handleRegexError                        ,
    catchPtyError                           ,
    handlePtyError                          ,

-- * Exported types
    WriteFlags(..)                          ,
    RegexError(..)                          ,
    PtyError(..)                            ,
    EraseBinding(..)                        ,
    CursorShape(..)                         ,
    CursorBlinkMode(..)                     ,


    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP


-- Enum WriteFlags
{- |
A flag type to determine how terminal contents should be written
to an output stream.
-}
data WriteFlags = 
      WriteFlagsDefault
    {- ^
    Write contents as UTF-8 text.  This is the default.
    -}
    | AnotherWriteFlags Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum WriteFlags where
    fromEnum WriteFlagsDefault = 0
    fromEnum (AnotherWriteFlags k) = k

    toEnum 0 = WriteFlagsDefault
    toEnum k = AnotherWriteFlags k

instance P.Ord WriteFlags where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

foreign import ccall "vte_write_flags_get_type" c_vte_write_flags_get_type :: 
    IO GType

instance BoxedEnum WriteFlags where
    boxedEnumType _ = c_vte_write_flags_get_type

-- Enum RegexError
{- |
An enum type for regex errors. In addition to the values listed above,
any PCRE2 error values may occur.

@since 0.46
-}
data RegexError = 
      RegexErrorIncompatible
    {- ^
    The PCRE2 library was built without
      Unicode support which is required for VTE
    -}
    | RegexErrorNotSupported
    {- ^
    Regexes are not supported because VTE was
      built without PCRE2 support
    -}
    | AnotherRegexError Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum RegexError where
    fromEnum RegexErrorIncompatible = 2147483646
    fromEnum RegexErrorNotSupported = 2147483647
    fromEnum (AnotherRegexError k) = k

    toEnum 2147483646 = RegexErrorIncompatible
    toEnum 2147483647 = RegexErrorNotSupported
    toEnum k = AnotherRegexError k

instance P.Ord RegexError where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

instance GErrorClass RegexError where
    gerrorClassDomain _ = "vte-regex-error"

catchRegexError ::
    IO a ->
    (RegexError -> GErrorMessage -> IO a) ->
    IO a
catchRegexError = catchGErrorJustDomain

handleRegexError ::
    (RegexError -> GErrorMessage -> IO a) ->
    IO a ->
    IO a
handleRegexError = handleGErrorJustDomain

foreign import ccall "vte_regex_error_get_type" c_vte_regex_error_get_type :: 
    IO GType

instance BoxedEnum RegexError where
    boxedEnumType _ = c_vte_regex_error_get_type

-- Enum PtyError
{- |
/No description available in the introspection data./
-}
data PtyError = 
      PtyErrorPtyHelperFailed
    {- ^
    Obsolete. Deprecated: 0.42
    -}
    | PtyErrorPty98Failed
    {- ^
    failure when using PTY98 to allocate the PTY
    -}
    | AnotherPtyError Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum PtyError where
    fromEnum PtyErrorPtyHelperFailed = 0
    fromEnum PtyErrorPty98Failed = 1
    fromEnum (AnotherPtyError k) = k

    toEnum 0 = PtyErrorPtyHelperFailed
    toEnum 1 = PtyErrorPty98Failed
    toEnum k = AnotherPtyError k

instance P.Ord PtyError where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

instance GErrorClass PtyError where
    gerrorClassDomain _ = "vte-pty-error"

catchPtyError ::
    IO a ->
    (PtyError -> GErrorMessage -> IO a) ->
    IO a
catchPtyError = catchGErrorJustDomain

handlePtyError ::
    (PtyError -> GErrorMessage -> IO a) ->
    IO a ->
    IO a
handlePtyError = handleGErrorJustDomain

foreign import ccall "vte_pty_error_get_type" c_vte_pty_error_get_type :: 
    IO GType

instance BoxedEnum PtyError where
    boxedEnumType _ = c_vte_pty_error_get_type

-- Enum EraseBinding
{- |
An enumerated type which can be used to indicate which string the terminal
should send to an application when the user presses the Delete or Backspace
keys.
-}
data EraseBinding = 
      EraseBindingAuto
    {- ^
    For backspace, attempt to determine the right value from the terminal\'s IO settings.  For delete, use the control sequence.
    -}
    | EraseBindingAsciiBackspace
    {- ^
    Send an ASCII backspace character (0x08).
    -}
    | EraseBindingAsciiDelete
    {- ^
    Send an ASCII delete character (0x7F).
    -}
    | EraseBindingDeleteSequence
    {- ^
    Send the \"\@/@7@/\" control sequence.
    -}
    | EraseBindingTty
    {- ^
    Send terminal\'s \"erase\" setting.
    -}
    | AnotherEraseBinding Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum EraseBinding where
    fromEnum EraseBindingAuto = 0
    fromEnum EraseBindingAsciiBackspace = 1
    fromEnum EraseBindingAsciiDelete = 2
    fromEnum EraseBindingDeleteSequence = 3
    fromEnum EraseBindingTty = 4
    fromEnum (AnotherEraseBinding k) = k

    toEnum 0 = EraseBindingAuto
    toEnum 1 = EraseBindingAsciiBackspace
    toEnum 2 = EraseBindingAsciiDelete
    toEnum 3 = EraseBindingDeleteSequence
    toEnum 4 = EraseBindingTty
    toEnum k = AnotherEraseBinding k

instance P.Ord EraseBinding where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

foreign import ccall "vte_erase_binding_get_type" c_vte_erase_binding_get_type :: 
    IO GType

instance BoxedEnum EraseBinding where
    boxedEnumType _ = c_vte_erase_binding_get_type

-- Enum CursorShape
{- |
An enumerated type which can be used to indicate what should the terminal
draw at the cursor position.
-}
data CursorShape = 
      CursorShapeBlock
    {- ^
    Draw a block cursor.  This is the default.
    -}
    | CursorShapeIbeam
    {- ^
    Draw a vertical bar on the left side of character.
    This is similar to the default cursor for other GTK+ widgets.
    -}
    | CursorShapeUnderline
    {- ^
    Draw a horizontal bar below the character.
    -}
    | AnotherCursorShape Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum CursorShape where
    fromEnum CursorShapeBlock = 0
    fromEnum CursorShapeIbeam = 1
    fromEnum CursorShapeUnderline = 2
    fromEnum (AnotherCursorShape k) = k

    toEnum 0 = CursorShapeBlock
    toEnum 1 = CursorShapeIbeam
    toEnum 2 = CursorShapeUnderline
    toEnum k = AnotherCursorShape k

instance P.Ord CursorShape where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

foreign import ccall "vte_cursor_shape_get_type" c_vte_cursor_shape_get_type :: 
    IO GType

instance BoxedEnum CursorShape where
    boxedEnumType _ = c_vte_cursor_shape_get_type

-- Enum CursorBlinkMode
{- |
An enumerated type which can be used to indicate the cursor blink mode
for the terminal.
-}
data CursorBlinkMode = 
      CursorBlinkModeSystem
    {- ^
    Follow GTK+ settings for cursor blinking.
    -}
    | CursorBlinkModeOn
    {- ^
    Cursor blinks.
    -}
    | CursorBlinkModeOff
    {- ^
    Cursor does not blink.
    -}
    | AnotherCursorBlinkMode Int
    -- ^ Catch-all for unknown values
    deriving (Show, Eq)

instance P.Enum CursorBlinkMode where
    fromEnum CursorBlinkModeSystem = 0
    fromEnum CursorBlinkModeOn = 1
    fromEnum CursorBlinkModeOff = 2
    fromEnum (AnotherCursorBlinkMode k) = k

    toEnum 0 = CursorBlinkModeSystem
    toEnum 1 = CursorBlinkModeOn
    toEnum 2 = CursorBlinkModeOff
    toEnum k = AnotherCursorBlinkMode k

instance P.Ord CursorBlinkMode where
    compare a b = P.compare (P.fromEnum a) (P.fromEnum b)

foreign import ccall "vte_cursor_blink_mode_get_type" c_vte_cursor_blink_mode_get_type :: 
    IO GType

instance BoxedEnum CursorBlinkMode where
    boxedEnumType _ = c_vte_cursor_blink_mode_get_type