From dc39d844b6be0ff7d2d8966139d2f6674e12287d Mon Sep 17 00:00:00 2001 From: Stevan Andjelkovic Date: Wed, 16 Mar 2022 15:04:57 +0100 Subject: [PATCH] refactor(debugger): fix warnings and rename some panels in ui --- src/new-debugger/src/Debugger/Main.hs | 3 +-- src/new-debugger/src/Debugger/UI.hs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/new-debugger/src/Debugger/Main.hs b/src/new-debugger/src/Debugger/Main.hs index fc918f69..fdbf084b 100644 --- a/src/new-debugger/src/Debugger/Main.hs +++ b/src/new-debugger/src/Debugger/Main.hs @@ -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) ------------------------------------------------------------------------ diff --git a/src/new-debugger/src/Debugger/UI.hs b/src/new-debugger/src/Debugger/UI.hs index ea69ac17..59e02b62 100644 --- a/src/new-debugger/src/Debugger/UI.hs +++ b/src/new-debugger/src/Debugger/UI.hs @@ -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) ------------------------------------------------------------------------ @@ -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 }