mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-22 22:31:30 +03:00
39 lines
874 B
Haskell
39 lines
874 B
Haskell
module Vere.Term.API (Ev(..), Client(..), trace, spin, stopSpin) where
|
|
|
|
import UrbitPrelude hiding (trace)
|
|
|
|
import Arvo (Blit, Belt)
|
|
|
|
|
|
-- 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 Text
|
|
| Blank
|
|
| Spinr (Maybe (Maybe Text))
|
|
|
|
data Client = Client
|
|
{ take :: STM Belt
|
|
, give :: Ev -> STM ()
|
|
}
|
|
|
|
|
|
-- Utilities -------------------------------------------------------------------
|
|
|
|
trace :: Client -> Text -> STM ()
|
|
trace ts = give ts . Trace
|
|
|
|
spin :: Client -> Maybe Text -> STM ()
|
|
spin ts = give ts . Spinr . Just
|
|
|
|
stopSpin :: Client -> STM ()
|
|
stopSpin ts = give ts (Spinr Nothing)
|