Skip to content

Commit 983053d

Browse files
warning cleanup2
1 parent 22eaeac commit 983053d

File tree

5 files changed

+15
-34
lines changed

5 files changed

+15
-34
lines changed

src/Potato/Reflex/Vty/Helpers.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module Potato.Reflex.Vty.Helpers (
3131
import Relude
3232

3333
import Potato.Reflex.Vty.Widget
34-
import Reflex.Potato.Helpers (simultaneous)
3534

3635
import Control.Monad.Fix
3736
import Control.Monad.NodeId
@@ -84,7 +83,7 @@ debugStream evs = do
8483
t <- holdDyn "" $ mergeWith (\a b -> a <> "\n" <> b) evs
8584
richText richTextConfig_simpleForeColorAttr (current t)
8685

87-
debugStreamBeh :: (MonadHold t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => [Behavior t Text] -> m ()
86+
debugStreamBeh :: (HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => [Behavior t Text] -> m ()
8887
debugStreamBeh behs = text $ foldr (liftA2 (\t1 t2 -> t1 <> " " <> t2)) "" behs
8988

9089
countEv :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Dynamic t Int)
@@ -135,18 +134,20 @@ dragAttachOnStart btn beh = mdo
135134
-}
136135

137136

137+
-- TODO DELETE UNUSED
138138
drag2AttachOnStart
139139
:: forall t m a. (Reflex t, MonadFix m, MonadHold t m, HasInput t m)
140140
=> V.Button
141141
-> Behavior t a
142142
-> m (Event t (a, Drag2))
143143
drag2AttachOnStart btn beh = do
144+
-- TODO pretty sure this should be btn?
144145
dragEv <- drag2 V.BLeft
145146
let
146147
foldfn d ma = do
147148
anew <- case ma of
148149
Nothing -> sample beh
149-
Just (a, _) | _drag2_state d == DragStart -> sample beh
150+
Just (_, _) | _drag2_state d == DragStart -> sample beh
150151
Just (a, _) -> return a
151152
return $ Just (anew, d)
152153
dragBeh <- foldDynM foldfn Nothing dragEv

src/Potato/Reflex/Vty/Widget.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import Reflex.Vty.Widget.Input.Mouse
4343

4444

4545
import Control.Monad.Fix
46-
import Control.Monad.NodeId
4746
import Control.Monad.Reader
4847
import System.Clock
4948

@@ -101,7 +100,7 @@ data DoubleClickConfig = DoubleClickConfig {
101100
, _dobuleClickConfig_button :: V.Button
102101
}
103102

104-
doubleClick :: (Reflex t, MonadHold t m, MonadFix m, PerformEvent t m, MonadIO (Performable m), HasInput t m) => DoubleClickConfig -> m (Event t ())
103+
doubleClick :: (MonadHold t m, MonadFix m, PerformEvent t m, MonadIO (Performable m), HasInput t m) => DoubleClickConfig -> m (Event t ())
105104
doubleClick DoubleClickConfig {..} = do
106105
singleClickEv <- singleClickNoDragOffSimple _dobuleClickConfig_button
107106
singleClickTimeEv <- performEvent $ ffor singleClickEv $ \_ -> do
@@ -113,7 +112,7 @@ doubleClick DoubleClickConfig {..} = do
113112
then Just ()
114113
else Nothing
115114

116-
doubleClickSimple :: (Reflex t, MonadHold t m, MonadFix m, PerformEvent t m, MonadIO (Performable m), HasInput t m) => m (Event t ())
115+
doubleClickSimple :: (MonadHold t m, MonadFix m, PerformEvent t m, MonadIO (Performable m), HasInput t m) => m (Event t ())
117116
doubleClickSimple = doubleClick DoubleClickConfig {
118117
--_doubleClickConfig_spaceTolerance = (0,0)
119118
_doubleClickConfig_timeTolerance = 300
@@ -127,7 +126,7 @@ integralFractionalDivide n d = fromIntegral n / fromIntegral d
127126
-- | A split of the available space into two parts with a draggable separator.
128127
-- Starts with half the space allocated to each, and the first pane has focus.
129128
-- Clicking in a pane switches focus.
130-
splitHDrag :: (Reflex t, MonadFix m, MonadHold t m, HasDisplayRegion t m, HasInput t m, HasImageWriter t m, HasFocusReader t m)
129+
splitHDrag :: (MonadFix m, MonadHold t m, HasDisplayRegion t m, HasInput t m, HasImageWriter t m, HasFocusReader t m)
131130
=> Int -- ^ initial width of left panel
132131
-> m ()
133132
-> m a

src/Potato/Reflex/Vty/Widget/Popup.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module Potato.Reflex.Vty.Widget.Popup (
99
import Relude
1010

1111
import Potato.Reflex.Vty.Helpers
12-
import Potato.Reflex.Vty.Widget
1312

1413
import qualified Graphics.Vty.Input.Events as V
1514
import Reflex

src/Potato/Reflex/Vty/Widget/ScrollBar.hs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@ import Potato.Reflex.Vty.Widget
1313

1414
import qualified Graphics.Vty as V
1515
import Reflex
16-
import Reflex.Network
17-
import Reflex.Potato.Helpers
1816
import Reflex.Vty
1917

20-
21-
import Data.Default
22-
import qualified Data.Sequence as Seq
23-
import Data.Fixed (div')
2418
import Data.These
2519
import Data.Align (align)
2620

@@ -54,18 +48,15 @@ onlyIfSimultaneous eva evb = fforMaybe (align eva evb) $ \case
5448
-- TODO write UTs
5549
-- TODO reduce constraints
5650
-- dynamically scaling vertical scroll bar
57-
vScrollBar :: forall t m a. (MonadWidget t m)
51+
vScrollBar :: forall t m. (MonadWidget t m)
5852
=> Int -- ^ width
5953
-> Dynamic t Int -- ^ content height
6054
-> m (Dynamic t Int) -- ^ offset
6155
vScrollBar scrollBarWidth contentSizeDyn = mdo
6256
maxSizeDyn <- displayHeight
6357
let
6458
screen_over_content_dyn :: Dynamic t Float = liftA2 (\a b -> fromIntegral a / fromIntegral b ) maxSizeDyn contentSizeDyn
65-
maxSizeDiffDyn = liftA2 (-) maxSizeDyn boxHeightDyn
66-
6759
maxContentSizeDiffDyn = fromIntegral . max 0 <$> liftA2 (-) contentSizeDyn maxSizeDyn
68-
6960
boxHeightDyn = fmap ceiling $ liftA2 (*) screen_over_content_dyn (fromIntegral <$> maxSizeDyn)
7061
boxRegionDyn = Region <$> 0 <*> offsetScreenUnitDyn <*> constDyn scrollBarWidth <*> boxHeightDyn
7162

src/Reflex/Vty/Test/Monad/Host.hs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ module Reflex.Vty.Test.Monad.Host (
2323
import Relude hiding (getFirst)
2424

2525
import Control.Monad.Ref
26-
import qualified Data.Map as Map
2726

2827
import qualified Graphics.Vty as V
29-
import Potato.Reflex.Vty.Widget
3028
import Reflex
3129
import Reflex.Host.Class
3230
import Reflex.Test.Monad.Host (MonadReflexTest (..), ReflexTestT,
@@ -36,13 +34,6 @@ import Reflex.Test.Monad.Host (MonadReflexTest (..), ReflexTestT,
3634
import Reflex.Vty
3735

3836

39-
-- for debug layout/widget stuff
40-
import Control.Monad.Fix
41-
import Data.Bimap (Bimap)
42-
import qualified Data.Bimap as Bimap
43-
import Data.Semigroup
44-
45-
4637

4738
-- | reflex-vty variant of 'ReflexTestT' which packages an 'VtyEvent' into the input and 'Behavior t [V.Image]' into the output
4839
-- 'uintref' and 'uout' allow user to add their own inputs and outputs
@@ -96,10 +87,10 @@ queueMouseEventInRegion :: (Reflex t, MonadSample t m, MonadRef m)
9687
queueMouseEventInRegion dr mouse = do
9788
let
9889
absCoords (Region l t _ _) (x,y) = (x+l, y+t)
99-
region <- sample . current $ dr
90+
reg <- sample . current $ dr
10091
case mouse of
101-
Left (MouseDown b c mods) -> queueVtyEvent $ uncurry V.EvMouseDown (absCoords region c) b mods
102-
Right (MouseUp b c) -> queueVtyEvent $ uncurry V.EvMouseUp (absCoords region c) b
92+
Left (MouseDown b c mods) -> queueVtyEvent $ uncurry V.EvMouseDown (absCoords reg c) b mods
93+
Right (MouseUp b c) -> queueVtyEvent $ uncurry V.EvMouseUp (absCoords reg c) b
10394

10495
-- | queue mouse event in a 'DynRegion'
10596
-- if (local) mouse coordinates are outside of the (absolute) region, returns False and does not queue any event
@@ -108,18 +99,18 @@ queueMouseEventInRegionGated :: (Reflex t, MonadSample t m, MonadRef m)
10899
-> Either MouseDown MouseUp -- ^ mouse coordinates are LOCAL to the input region
109100
-> ReflexVtyTestT t uintref uout m Bool
110101
queueMouseEventInRegionGated dr mouse = do
111-
region <- sample . current $ dr
102+
reg <- sample . current $ dr
112103
let
113104
absCoords (Region l t _ _) (x,y) = (x+l, y+t)
114105
coordinates = case mouse of
115106
Left (MouseDown _ c _) -> c
116107
Right (MouseUp _ c) -> c
117108
withinRegion (Region _ _ w h) (x,y) = not $ or [ x < 0, y < 0, x >= w, y >= h ]
118-
if withinRegion region coordinates
109+
if withinRegion reg coordinates
119110
then do
120111
case mouse of
121-
Left (MouseDown b c mods) -> queueVtyEvent $ uncurry V.EvMouseDown (absCoords region c) b mods
122-
Right (MouseUp b c) -> queueVtyEvent $ uncurry V.EvMouseUp (absCoords region c) b
112+
Left (MouseDown b c mods) -> queueVtyEvent $ uncurry V.EvMouseDown (absCoords reg c) b mods
113+
Right (MouseUp b c) -> queueVtyEvent $ uncurry V.EvMouseUp (absCoords reg c) b
123114
return True
124115
else return False
125116

0 commit comments

Comments
 (0)