Skip to content

Commit

Permalink
Merge pull request #559 from symbiont-io/journal
Browse files Browse the repository at this point in the history
refactor(debugger): fix warnings and rename some panels in ui
  • Loading branch information
symbiont-stevan-andjelkovic authored Mar 16, 2022
2 parents 1d7f31a + dc39d84 commit 0a248a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/new-debugger/src/Debugger/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import Brick.BChan
import Control.Concurrent
import Control.Exception (finally)
import Data.Aeson (decodeFileStrict)
import qualified Data.Vector as Vector
import System.Environment (getArgs)
import System.Exit (die)

import Debugger.State
import Debugger.UI (AppEvent(UpdateState), AppState, mkAppState, runApp)
import Debugger.UI (AppEvent(UpdateState), mkAppState, runApp)

------------------------------------------------------------------------

Expand Down
17 changes: 10 additions & 7 deletions src/new-debugger/src/Debugger/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import qualified Data.Vector as Vector
import qualified Graphics.Vty as V
import Text.Wrap

import Debugger.State
import Debugger.State hiding (to, from, event, receivedLogical)

------------------------------------------------------------------------

Expand All @@ -25,25 +25,28 @@ drawUI as = [ui]
$ vBox
[ hBox
[ vBox
[ borderWithLabel (str "Reactor State") $ renderReactorState as
[ borderWithLabel (str "State") $ renderReactorState as
, vLimitPercent 33 $ borderWithLabel (str "Events") $ renderEvents as
]
, borderWithLabel (str "Sequence Diagram") $ renderSeqDia as
]
, vLimit 7 $ hBox
[ borderWithLabel (str "Current Message") $ renderMessage as
, borderWithLabel (str "Sent Messages") $ renderSentMessage as
[ borderWithLabel (str "Input") $ renderMessage as
, borderWithLabel (str "Output") $ renderSentMessage as
]
, vLimit 7 $ borderWithLabel (str "Reactor Log") $ renderLogs as
, vLimit 7 $ borderWithLabel (str "Logs") $ renderLogs as
]

renderEvent :: Bool -> DebEvent -> String
renderEvent showMsg (DebEvent from to event receivedLogical msg) =
event <> ": " <> from <> " -> " <> to <> " @ " <> show receivedLogical <> if showMsg then " : " <> msg else mempty
event <> ": " <> from <> " -> " <> to <> " @ " <> show receivedLogical
<> if showMsg then " : " <> msg else mempty

renderToString :: AppState -> (InstanceState -> String) -> Widget ()
renderToString as f = center$ strWrapWith wrapSettings (fromMaybe "?" . fmap (f . snd) $ L.listSelectedElement $ asLog as)
renderToString as f = center $ strWrapWith wrapSettings
(fromMaybe "?" . fmap (f . snd) $ L.listSelectedElement $ asLog as)

wrapSettings :: WrapSettings
wrapSettings = defaultWrapSettings
{ preserveIndentation = False, breakLongWords = True }

Expand Down

0 comments on commit 0a248a3

Please sign in to comment.