for package:yi

Runs a YiM action in a separate thread. Notes:
  • It seems to work but I don't know why
  • Maybe deadlocks?
  • If you're outputting into the Yi window, you should really limit the rate at which you do so: for example, the Pango front-end will quite happily segfault/double-free if you output too fast.
I am exporting this for those adventurous to play with but I have only discovered how to do this a night before the release so it's rather experimental. A simple function that prints a message once a second, 5 times, could be written like this:
printer :: YiM ThreadId
printer = do
mv <- io $ newMVar (0 :: Int)
forkAction (suicide mv) MustRefresh $ do
c <- io $ do
modifyMVar_ mv (return . succ)
tryReadMVar mv
case c of
Nothing -> printMsg "messaging unknown time"
Just x -> printMsg $ "message #" <> showT x
where
suicide mv = tryReadMVar mv >>= case
Just i | i >= 5 -> return True
_ -> threadDelay 1000000 >> return False
Forces all windows in the tab
Transforms the region given by TextUnit in the Direction with user-supplied function.
Displays help for a given name, or help index, if no name is given
Prompts for a buffer name, turns it into a BufferRef and passes it on to the handler function. Uses all known buffers for hinting.
User force-refresh (in case the screen has been messed up from outside)