module AutoGUI.Debug
  ( pause
  , failsafe
  , sleep
  )
where

import AutoGUI.Discard

import Control.Concurrent
import CPython.Simple
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Float.RealFracMethods

-- | Set a number of seconds to wait in between autogui actions
pause :: Double -> IO ()
pause :: Double -> IO ()
pause = Text -> Text -> Double -> IO ()
forall a. ToPy a => Text -> Text -> a -> IO ()
setAttribute Text
"pyautogui" Text
"PAUSE"

-- | When set to true, move the mouse to the upper-left corner of the screen to throw
--   a Python exception, and quit the program
failsafe :: Bool -> IO ()
failsafe :: Bool -> IO ()
failsafe = Text -> Text -> Bool -> IO ()
forall a. ToPy a => Text -> Text -> a -> IO ()
setAttribute Text
"pyautogui" Text
"FAILSAFE"

-- | Sleep for a given fractional number of seconds
sleep :: Double -> IO ()
sleep :: Double -> IO ()
sleep Double
n = Int -> IO ()
threadDelay (Int -> IO ()) -> (Double -> Int) -> Double -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Int
forall a. Num a => Integer -> a
fromInteger (Integer -> Int) -> (Double -> Integer) -> Double -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Integer
roundDoubleInteger (Double -> IO ()) -> Double -> IO ()
forall a b. (a -> b) -> a -> b
$ Double
n Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
1000000