module Hydra.TUI.Handlers.Global where

import Brick (EventM)
import Brick.Main (halt)
import Graphics.Vty (Event (..), Key (..), Modifier (..))
import Graphics.Vty qualified as Vty
import Hydra.Prelude

handleVtyQuitEvents :: Vty.Event -> EventM n s ()
handleVtyQuitEvents :: forall n s. Event -> EventM n s ()
handleVtyQuitEvents = \case
  EvKey (KChar Char
'c') [Modifier
MCtrl] -> EventM n s ()
forall n s. EventM n s ()
halt
  EvKey (KChar Char
'd') [Modifier
MCtrl] -> EventM n s ()
forall n s. EventM n s ()
halt
  EvKey (KChar Char
'q') [] -> EventM n s ()
forall n s. EventM n s ()
halt
  EvKey (KChar Char
'Q') [] -> EventM n s ()
forall n s. EventM n s ()
halt
  Event
_ -> () -> EventM n s ()
forall a. a -> EventM n s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

handleVtyGlobalEvents :: Vty.Event -> EventM n s ()
handleVtyGlobalEvents :: forall n s. Event -> EventM n s ()
handleVtyGlobalEvents Event
e = do
  Event -> EventM n s ()
forall n s. Event -> EventM n s ()
handleVtyQuitEvents Event
e