Skip to content

Commit

Permalink
build fix for web
Browse files Browse the repository at this point in the history
  • Loading branch information
wavewave committed Apr 29, 2023
1 parent 7d2ddb7 commit 0af5752
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 87 deletions.
59 changes: 0 additions & 59 deletions daemon/app/font-test/Main.hs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module GHCSpecter.Web.ConcurReplicaSVG (
makePolylineText,
Expand Down Expand Up @@ -29,6 +30,7 @@ import GHCSpecter.Graphics.DSL (
Rectangle (..),
Shape (..),
)
import GHCSpecter.Layouter.Text (MonadTextLayout (..))
import Text.Printf (printf)
import Prelude hiding (div)

Expand Down Expand Up @@ -97,3 +99,9 @@ renderPrimitive _ (Primitive (SDrawText (DrawText (x, y) _pos _font color _fontS
, SP.pointerEvents "none"
]
[text msg]

-- This is a dummy implementation. There are no easy way to get text dimension from web in concur-replica.
-- TODO: at least, this should produce a reasonable size, not fixed 120.
instance MonadTextLayout (Widget IHTML) where
calculateTextDimension _ font_size _ =
pure (120, fromIntegral font_size + 3)
16 changes: 8 additions & 8 deletions daemon/app/ghc-specter-daemon/GHCSpecter/Web/ModuleGraph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ renderModuleGraph
nameMap
valueFor
grVisInfo
(mfocused, mhinted) =
(mfocused, mhinted) = do
let Dim canvasWidth canvasHeight = grVisInfo ^. gviCanvasDim
handlers hitEvent =
catMaybes
[ fmap (\ev -> ev <$ onMouseEnter) (hitEventHoverOn hitEvent)
, fmap (\ev -> ev <$ onMouseLeave) (hitEventHoverOff hitEvent)
, fmap (\ev -> fromEither ev <$ onClick) (hitEventClick hitEvent)
]
scene = buildModuleGraph nameMap valueFor grVisInfo (mfocused, mhinted)
rexp = sceneElements scene
svgProps =
scene <- buildModuleGraph nameMap valueFor grVisInfo (mfocused, mhinted)
let rexp = sceneElements scene
let svgProps =
[ width (T.pack (show (canvasWidth + 100)))
, SP.viewBox
( "0 0 "
Expand All @@ -126,14 +126,14 @@ renderModuleGraph
( S.style [] [text ".small { font: 6px Courier,monospace; } text { user-select: none; }"]
: fmap (renderPrimitive handlers) rexp
)
in div [classList [("is-fullwidth", True)]] [svgElement]
div [classList [("is-fullwidth", True)]] [svgElement]

-- | render graph more simply
renderGraph :: (Text -> Bool) -> GraphVisInfo -> Widget IHTML a
renderGraph cond grVisInfo =
renderGraph cond grVisInfo = do
let Dim canvasWidth canvasHeight = grVisInfo ^. gviCanvasDim
rexp = buildGraph cond grVisInfo
svgProps =
rexp <- buildGraph cond grVisInfo
let svgProps =
[ width (T.pack (show (canvasWidth + 100)))
, SP.viewBox
( "0 0 "
Expand Down
12 changes: 6 additions & 6 deletions daemon/app/ghc-specter-daemon/GHCSpecter/Web/Timing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ renderTimingChart ::
TimingUI ->
TimingTable ->
Widget IHTML Event
renderTimingChart drvModMap tui ttable =
renderTimingChart drvModMap tui ttable = do
scene <- TimingView.buildTimingChart drvModMap tui ttable
let rexp = sceneElements scene
S.svg
svgProps
[ S.style [] [text ".small { font: 5px sans-serif; } text { user-select: none; }"]
Expand All @@ -113,8 +115,6 @@ renderTimingChart drvModMap tui ttable =
[ fmap (\ev -> TimingEv ev <$ onMouseEnter) (hitEventHoverOn hitEvent)
, fmap (\ev -> TimingEv ev <$ onMouseLeave) (hitEventHoverOn hitEvent)
]
scene = TimingView.buildTimingChart drvModMap tui ttable
rexp = sceneElements scene
vpi = tui ^. timingUIViewPort
vp = fromMaybe (vpi ^. vpViewPort) (vpi ^. vpTempViewPort)
svgProps =
Expand Down Expand Up @@ -145,15 +145,15 @@ renderMemChart ::
TimingUI ->
TimingTable ->
Widget IHTML Event
renderMemChart drvModMap tui ttable =
renderMemChart drvModMap tui ttable = do
scene <- TimingView.buildMemChart drvModMap tui ttable
let rexp = sceneElements scene
S.svg
svgProps
[ S.style [] [text ".small { font: 5px sans-serif; } text { user-select: none; }"]
, S.g [] (fmap (renderPrimitive (const [])) rexp)
]
where
scene = TimingView.buildMemChart drvModMap tui ttable
rexp = sceneElements scene
vpi = tui ^. timingUIViewPort
vp = fromMaybe (vpi ^. vpViewPort) (vpi ^. vpTempViewPort)
viewboxProp =
Expand Down
14 changes: 0 additions & 14 deletions daemon/ghc-specter-daemon.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,6 @@ executable ghc-specter-daemon
, websockets
default-language: GHC2021

executable font-test
main-is: Main.hs
hs-source-dirs:
app/font-test
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.15 && <5
, ghc-specter-daemon
, ghc-specter-render
, gi-pango
, gi-pangocairo
, transformers
default-language: GHC2021

test-suite ghc-specter-daemon-test
type: exitcode-stdio-1.0
main-is: Spec.hs
Expand Down

0 comments on commit 0af5752

Please sign in to comment.