Skip to content

Commit

Permalink
feat(runtime): display message content on right hand side in debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Oct 5, 2021
1 parent 4d5143e commit 188f05e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/runtime-prototype/src/Debugger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,39 @@ readLog = do
return (read s)

drawUI :: AppState -> [Widget ()]
drawUI (AppState l) = [ui]
drawUI as = [ui]
where
ui = withBorderStyle unicode
$ borderWithLabel (str "Debugger")
$ (center (L.renderList listDrawElement True l) <+> vBorder <+> center (str "Right"))
$ hBox [ center (L.renderList listDrawElement True (asLog as))
, vBorder
, center (str (displaySelectedMessage as))
]

listDrawElement :: Bool -> Timestamped LogEntry -> Widget ()
listDrawElement sel (Timestamped le lt pt) =
listDrawElement sel (Timestamped le (LogicalTimestamp (NodeName nn) lt) pt) =
let selStr s = if sel
then withAttr customAttr (str $ "<" <> s <> ">")
else str s
in hCenter $ selStr $ show le ++ " " ++ show lt ++ " " ++ show pt
in selStr $ display le ++ " " ++ nn ++ " " ++ show lt ++ " " ++ show pt

display :: LogEntry -> String
display (LogSend (LocalRef i) (RemoteRef a j) msg)
= show i ++ " --> " ++ show j ++ "@" ++ a
display (LogResumeContinuation (RemoteRef a i) (LocalRef j) msg)
= show j ++ " <-- " ++ show i ++ "@" ++ a

displaySelectedMessage :: AppState -> String
displaySelectedMessage as = case L.listSelectedElement (asLog as) of
Nothing -> "?"
Just (_ix, Timestamped (LogSend _from _to msg) _lt _pt) -> show msg
Just (_ix, Timestamped (LogResumeContinuation _from _to msg) _lt _pt) -> show msg

customAttr :: AttrName
customAttr = L.listSelectedAttr <> "custom"

app :: App AppState e ()
app = App
brickApp :: App AppState e ()
brickApp = App
{ appDraw = drawUI
, appHandleEvent = appEvent
, appStartEvent = return
Expand Down Expand Up @@ -79,4 +94,4 @@ initialState (Log es) = AppState
main :: IO ()
main = do
l <- readLog
void (defaultMain app (initialState l))
void (defaultMain brickApp (initialState l))
1 change: 0 additions & 1 deletion src/runtime-prototype/src/StuntDouble/ActorMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ actorMapTurn' p acc lref t seed l (Free op) am = case op of
DumpLog k ->
actorMapTurn' p acc lref t seed l (k l) am


actorMapGetState :: Typeable s => LocalRef -> ActorMap -> (s, ActorMap)
actorMapGetState lref am = case actorMapUnsafeLookup lref am of
ActorData _a s' _t -> case cast s' of
Expand Down

0 comments on commit 188f05e

Please sign in to comment.