kmonad-0.4.1: Advanced keyboard remapping utility
Copyright(c) David Janssen 2019
Safe HaskellNone



For certain KMonad operations we need to be able to pause and resume processing of events. This component provides the ability to temporarily pause processing, and then resume processing and return all events that were caught while paused.



data Sluice Source #

The Sluice environment.

NOTE: Sluice has no internal multithreading, i.e. its pull action will never be interrupted, therefore we can simply use IORef and sidestep all the STM complications.

mkSluice :: MonadUnliftIO m => m KeyEvent -> ContT r m Sluice Source #

Create a new Sluice environment, but do so in a ContT context

block :: HasLogFunc e => Sluice -> RIO e () Source #

Increase the block-count by 1

unblock :: HasLogFunc e => Sluice -> RIO e [KeyEvent] Source #

Set the Sluice to unblocked mode, return a list of all the stored events that should be rerun, in the correct order (head was first-in, etc).

NOTE: After successfully unblocking the Sluice will be empty, it is the caller's responsibility to insert the returned events at an appropriate location in the App.

We do this in KMonad by writing the events into the Dispatchs rerun buffer. (this happens in the KMonad.App module.)

pull :: HasLogFunc e => Sluice -> RIO e KeyEvent Source #

Keep trying to read from the Sluice until an event passes through