mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-22 14:21:34 +03:00
8d3e15c62b
At least some of the parsed plea structures were holding on to the raw bytestrings through laziness.
45 lines
1014 B
Haskell
45 lines
1014 B
Haskell
{-|
|
|
Interface Terminal API.
|
|
-}
|
|
module Urbit.Vere.Term.API (Ev(..), Client(..), trace, spin, stopSpin) where
|
|
|
|
import Urbit.Prelude hiding (trace)
|
|
|
|
import Urbit.Arvo (Belt, Blit)
|
|
|
|
|
|
-- External Types --------------------------------------------------------------
|
|
|
|
{-|
|
|
Input Event for terminal driver:
|
|
|
|
%blits -- list of blits from arvo.
|
|
%trace -- stderr line from runtime.
|
|
%blank -- print a blank line
|
|
%spinr -- Start or stop the spinner
|
|
-}
|
|
data Ev = Blits ![Blit]
|
|
| Trace !Cord
|
|
| Blank
|
|
| Spinr !(Maybe (Maybe Cord))
|
|
deriving (Show)
|
|
|
|
data Client = Client
|
|
{ take :: STM (Maybe Belt)
|
|
, give :: [Ev] -> STM ()
|
|
}
|
|
|
|
deriveNoun ''Ev
|
|
|
|
|
|
-- Utilities -------------------------------------------------------------------
|
|
|
|
trace :: Client -> Text -> STM ()
|
|
trace ts = give ts . singleton . Trace . Cord
|
|
|
|
spin :: Client -> Maybe Text -> STM ()
|
|
spin ts = give ts . singleton . Spinr . Just . fmap Cord
|
|
|
|
stopSpin :: Client -> STM ()
|
|
stopSpin ts = give ts [Spinr Nothing]
|