mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-22 14:21:34 +03:00
e9f09e32c1
If you connect to an urbit using the remote terminal code, slogs would not be printed to them since they were hard coded to be printed to stderr. This threads slog printing to the terminal driver, and puts them in scrollback. (It does not actually fix slogs being printed on one line.)
55 lines
1.3 KiB
Haskell
55 lines
1.3 KiB
Haskell
{-|
|
|
Interface Terminal API.
|
|
-}
|
|
module Urbit.Vere.Term.API (Ev(..),
|
|
Client(..),
|
|
trace,
|
|
slog,
|
|
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.
|
|
%slog -- nock worker logging with priority
|
|
%blank -- print a blank line
|
|
%spinr -- Start or stop the spinner
|
|
-}
|
|
data Ev = Blits [Blit]
|
|
| Trace Cord
|
|
| Slog (Atom, Tank)
|
|
| 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
|
|
|
|
slog :: Client -> (Atom, Tank) -> STM ()
|
|
slog ts = give ts . singleton . Slog
|
|
|
|
spin :: Client -> Maybe Text -> STM ()
|
|
spin ts = give ts . singleton . Spinr . Just . fmap Cord
|
|
|
|
stopSpin :: Client -> STM ()
|
|
stopSpin ts = give ts [Spinr Nothing]
|