    {-# Language DeriveGeneric #-}
    {-# Language StrictData #-}
    module Graphics.Vty.Input.Events
      ( Key(..)
      , Modifier(..)
      , Event(..)
      , Button(..)
      , ClassifyMap
      , InternalEvent(..)
      )
    where

    import Control.DeepSeq
    import Data.ByteString
    import GHC.Generics

    -- | Representations of non-modifier keys.
    --
    -- * KFun is indexed from 0 to 63. Range of supported FKeys varies by
    -- terminal and keyboard.
    --
    -- * KUpLeft, KUpRight, KDownLeft, KDownRight, KCenter support varies by
    -- terminal and keyboard.
    --
    -- * Actually, support for most of these but KEsc, KChar, KBS, and
    -- KEnter vary by terminal and keyboard.
    data Key = KEsc  | KChar {-# UNPACK #-} Char | KBS | KEnter
             | KLeft | KRight | KUp | KDown
             | KUpLeft | KUpRight | KDownLeft | KDownRight | KCenter
             | KFun {-# UNPACK #-} Int | KBackTab | KPrtScr | KPause | KIns
             | KHome | KPageUp | KDel | KEnd | KPageDown | KBegin | KMenu
        deriving (Key -> Key -> Bool
    (Key -> Key -> Bool) -> (Key -> Key -> Bool) -> Eq Key
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Key -> Key -> Bool
    == :: Key -> Key -> Bool
    $c/= :: Key -> Key -> Bool
    /= :: Key -> Key -> Bool
    Eq, Int -> Key -> ShowS
    [Key] -> ShowS
    Key -> String
    (Int -> Key -> ShowS)
    -> (Key -> String) -> ([Key] -> ShowS) -> Show Key
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Key -> ShowS
    showsPrec :: Int -> Key -> ShowS
    $cshow :: Key -> String
    show :: Key -> String
    $cshowList :: [Key] -> ShowS
    showList :: [Key] -> ShowS
    Show, ReadPrec [Key]
    ReadPrec Key
    Int -> ReadS Key
    ReadS [Key]
    (Int -> ReadS Key)
    -> ReadS [Key] -> ReadPrec Key -> ReadPrec [Key] -> Read Key
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Key
    readsPrec :: Int -> ReadS Key
    $creadList :: ReadS [Key]
    readList :: ReadS [Key]
    $creadPrec :: ReadPrec Key
    readPrec :: ReadPrec Key
    $creadListPrec :: ReadPrec [Key]
    readListPrec :: ReadPrec [Key]
    Read, Eq Key
    Eq Key =>
    (Key -> Key -> Ordering)
    -> (Key -> Key -> Bool)
    -> (Key -> Key -> Bool)
    -> (Key -> Key -> Bool)
    -> (Key -> Key -> Bool)
    -> (Key -> Key -> Key)
    -> (Key -> Key -> Key)
    -> Ord Key
    Key -> Key -> Bool
    Key -> Key -> Ordering
    Key -> Key -> Key
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Key -> Key -> Ordering
    compare :: Key -> Key -> Ordering
    $c< :: Key -> Key -> Bool
    < :: Key -> Key -> Bool
    $c<= :: Key -> Key -> Bool
    <= :: Key -> Key -> Bool
    $c> :: Key -> Key -> Bool
    > :: Key -> Key -> Bool
    $c>= :: Key -> Key -> Bool
    >= :: Key -> Key -> Bool
    $cmax :: Key -> Key -> Key
    max :: Key -> Key -> Key
    $cmin :: Key -> Key -> Key
    min :: Key -> Key -> Key
    Ord, (forall x. Key -> Rep Key x)
    -> (forall x. Rep Key x -> Key) -> Generic Key
    forall x. Rep Key x -> Key
    forall x. Key -> Rep Key x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Key -> Rep Key x
    from :: forall x. Key -> Rep Key x
    $cto :: forall x. Rep Key x -> Key
    to :: forall x. Rep Key x -> Key
    Generic)

    instance NFData Key

    -- | Modifier keys. Key codes are interpreted such that users are more
    -- likely to have Meta than Alt; for instance on the PC Linux console,
    -- 'MMeta' will generally correspond to the physical Alt key.
    data Modifier = MShift | MCtrl | MMeta | MAlt
        deriving (Modifier -> Modifier -> Bool
    (Modifier -> Modifier -> Bool)
    -> (Modifier -> Modifier -> Bool) -> Eq Modifier
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Modifier -> Modifier -> Bool
    == :: Modifier -> Modifier -> Bool
    $c/= :: Modifier -> Modifier -> Bool
    /= :: Modifier -> Modifier -> Bool
    Eq, Int -> Modifier -> ShowS
    [Modifier] -> ShowS
    Modifier -> String
    (Int -> Modifier -> ShowS)
    -> (Modifier -> String) -> ([Modifier] -> ShowS) -> Show Modifier
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Modifier -> ShowS
    showsPrec :: Int -> Modifier -> ShowS
    $cshow :: Modifier -> String
    show :: Modifier -> String
    $cshowList :: [Modifier] -> ShowS
    showList :: [Modifier] -> ShowS
    Show, ReadPrec [Modifier]
    ReadPrec Modifier
    Int -> ReadS Modifier
    ReadS [Modifier]
    (Int -> ReadS Modifier)
    -> ReadS [Modifier]
    -> ReadPrec Modifier
    -> ReadPrec [Modifier]
    -> Read Modifier
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Modifier
    readsPrec :: Int -> ReadS Modifier
    $creadList :: ReadS [Modifier]
    readList :: ReadS [Modifier]
    $creadPrec :: ReadPrec Modifier
    readPrec :: ReadPrec Modifier
    $creadListPrec :: ReadPrec [Modifier]
    readListPrec :: ReadPrec [Modifier]
    Read, Eq Modifier
    Eq Modifier =>
    (Modifier -> Modifier -> Ordering)
    -> (Modifier -> Modifier -> Bool)
    -> (Modifier -> Modifier -> Bool)
    -> (Modifier -> Modifier -> Bool)
    -> (Modifier -> Modifier -> Bool)
    -> (Modifier -> Modifier -> Modifier)
    -> (Modifier -> Modifier -> Modifier)
    -> Ord Modifier
    Modifier -> Modifier -> Bool
    Modifier -> Modifier -> Ordering
    Modifier -> Modifier -> Modifier
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Modifier -> Modifier -> Ordering
    compare :: Modifier -> Modifier -> Ordering
    $c< :: Modifier -> Modifier -> Bool
    < :: Modifier -> Modifier -> Bool
    $c<= :: Modifier -> Modifier -> Bool
    <= :: Modifier -> Modifier -> Bool
    $c> :: Modifier -> Modifier -> Bool
    > :: Modifier -> Modifier -> Bool
    $c>= :: Modifier -> Modifier -> Bool
    >= :: Modifier -> Modifier -> Bool
    $cmax :: Modifier -> Modifier -> Modifier
    max :: Modifier -> Modifier -> Modifier
    $cmin :: Modifier -> Modifier -> Modifier
    min :: Modifier -> Modifier -> Modifier
    Ord, (forall x. Modifier -> Rep Modifier x)
    -> (forall x. Rep Modifier x -> Modifier) -> Generic Modifier
    forall x. Rep Modifier x -> Modifier
    forall x. Modifier -> Rep Modifier x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Modifier -> Rep Modifier x
    from :: forall x. Modifier -> Rep Modifier x
    $cto :: forall x. Rep Modifier x -> Modifier
    to :: forall x. Rep Modifier x -> Modifier
    Generic)

    instance NFData Modifier

    -- | Mouse buttons.
    data Button = BLeft | BMiddle | BRight | BScrollUp | BScrollDown
        deriving (Button -> Button -> Bool
    (Button -> Button -> Bool)
    -> (Button -> Button -> Bool) -> Eq Button
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Button -> Button -> Bool
    == :: Button -> Button -> Bool
    $c/= :: Button -> Button -> Bool
    /= :: Button -> Button -> Bool
    Eq, Int -> Button -> ShowS
    [Button] -> ShowS
    Button -> String
    (Int -> Button -> ShowS)
    -> (Button -> String) -> ([Button] -> ShowS) -> Show Button
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Button -> ShowS
    showsPrec :: Int -> Button -> ShowS
    $cshow :: Button -> String
    show :: Button -> String
    $cshowList :: [Button] -> ShowS
    showList :: [Button] -> ShowS
    Show, ReadPrec [Button]
    ReadPrec Button
    Int -> ReadS Button
    ReadS [Button]
    (Int -> ReadS Button)
    -> ReadS [Button]
    -> ReadPrec Button
    -> ReadPrec [Button]
    -> Read Button
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Button
    readsPrec :: Int -> ReadS Button
    $creadList :: ReadS [Button]
    readList :: ReadS [Button]
    $creadPrec :: ReadPrec Button
    readPrec :: ReadPrec Button
    $creadListPrec :: ReadPrec [Button]
    readListPrec :: ReadPrec [Button]
    Read, Eq Button
    Eq Button =>
    (Button -> Button -> Ordering)
    -> (Button -> Button -> Bool)
    -> (Button -> Button -> Bool)
    -> (Button -> Button -> Bool)
    -> (Button -> Button -> Bool)
    -> (Button -> Button -> Button)
    -> (Button -> Button -> Button)
    -> Ord Button
    Button -> Button -> Bool
    Button -> Button -> Ordering
    Button -> Button -> Button
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Button -> Button -> Ordering
    compare :: Button -> Button -> Ordering
    $c< :: Button -> Button -> Bool
    < :: Button -> Button -> Bool
    $c<= :: Button -> Button -> Bool
    <= :: Button -> Button -> Bool
    $c> :: Button -> Button -> Bool
    > :: Button -> Button -> Bool
    $c>= :: Button -> Button -> Bool
    >= :: Button -> Button -> Bool
    $cmax :: Button -> Button -> Button
    max :: Button -> Button -> Button
    $cmin :: Button -> Button -> Button
    min :: Button -> Button -> Button
    Ord, (forall x. Button -> Rep Button x)
    -> (forall x. Rep Button x -> Button) -> Generic Button
    forall x. Rep Button x -> Button
    forall x. Button -> Rep Button x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Button -> Rep Button x
    from :: forall x. Button -> Rep Button x
    $cto :: forall x. Rep Button x -> Button
    to :: forall x. Rep Button x -> Button
    Generic)

    instance NFData Button

    -- | Events.
    data Event
        = EvKey Key [Modifier]
        -- ^ A keyboard key was pressed with the specified modifiers.
        | EvMouseDown Int Int Button [Modifier]
        -- ^ A mouse button was pressed at the specified column and row. Any
        -- modifiers available in the event are also provided.
        | EvMouseUp Int Int (Maybe Button)
        -- ^ A mouse button was released at the specified column and
        -- row. Some terminals report only that a button was released
        -- without specifying which one; in that case, Nothing is provided.
        -- Otherwise Just the button released is included in the event.
        | EvResize Int Int
        -- The terminal window was resized and the size is provided in the
        -- integer fields (width, height).
        | EvPaste ByteString
        -- ^ A paste event occurs when a bracketed paste input sequence is
        -- received. For terminals that support bracketed paste mode, these
        -- events will be triggered on a paste event. Terminals that do not
        -- support bracketed pastes will send the paste contents as ordinary
        -- input (which is probably bad, so beware!) Note that the data is
        -- provided in raw form and you'll have to decode (e.g. as UTF-8) if
        -- that's what your application expects.
        | EvLostFocus
        -- ^ The terminal running the application lost input focus.
        | EvGainedFocus
        -- ^ The terminal running the application gained input focus.
        deriving (Event -> Event -> Bool
    (Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Event -> Event -> Bool
    == :: Event -> Event -> Bool
    $c/= :: Event -> Event -> Bool
    /= :: Event -> Event -> Bool
    Eq, Int -> Event -> ShowS
    [Event] -> ShowS
    Event -> String
    (Int -> Event -> ShowS)
    -> (Event -> String) -> ([Event] -> ShowS) -> Show Event
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Event -> ShowS
    showsPrec :: Int -> Event -> ShowS
    $cshow :: Event -> String
    show :: Event -> String
    $cshowList :: [Event] -> ShowS
    showList :: [Event] -> ShowS
    Show, ReadPrec [Event]
    ReadPrec Event
    Int -> ReadS Event
    ReadS [Event]
    (Int -> ReadS Event)
    -> ReadS [Event]
    -> ReadPrec Event
    -> ReadPrec [Event]
    -> Read Event
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Event
    readsPrec :: Int -> ReadS Event
    $creadList :: ReadS [Event]
    readList :: ReadS [Event]
    $creadPrec :: ReadPrec Event
    readPrec :: ReadPrec Event
    $creadListPrec :: ReadPrec [Event]
    readListPrec :: ReadPrec [Event]
    Read, Eq Event
    Eq Event =>
    (Event -> Event -> Ordering)
    -> (Event -> Event -> Bool)
    -> (Event -> Event -> Bool)
    -> (Event -> Event -> Bool)
    -> (Event -> Event -> Bool)
    -> (Event -> Event -> Event)
    -> (Event -> Event -> Event)
    -> Ord Event
    Event -> Event -> Bool
    Event -> Event -> Ordering
    Event -> Event -> Event
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Event -> Event -> Ordering
    compare :: Event -> Event -> Ordering
    $c< :: Event -> Event -> Bool
    < :: Event -> Event -> Bool
    $c<= :: Event -> Event -> Bool
    <= :: Event -> Event -> Bool
    $c> :: Event -> Event -> Bool
    > :: Event -> Event -> Bool
    $c>= :: Event -> Event -> Bool
    >= :: Event -> Event -> Bool
    $cmax :: Event -> Event -> Event
    max :: Event -> Event -> Event
    $cmin :: Event -> Event -> Event
    min :: Event -> Event -> Event
    Ord, (forall x. Event -> Rep Event x)
    -> (forall x. Rep Event x -> Event) -> Generic Event
    forall x. Rep Event x -> Event
    forall x. Event -> Rep Event x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Event -> Rep Event x
    from :: forall x. Event -> Rep Event x
    $cto :: forall x. Rep Event x -> Event
    to :: forall x. Rep Event x -> Event
    Generic)

    instance NFData Event

    type ClassifyMap = [(String,Event)]

    -- | The type of internal events that drive the internal Vty event
    -- dispatching to the application.
    data InternalEvent =
        ResumeAfterInterrupt
        -- ^ Vty resumed operation after the process was interrupted (e.g.
        -- with a signal). In practice this translates into a screen redraw
        -- in the input event loop.
        | InputEvent Event
        -- ^ An input event was received.