Skip to content

Commit 916c90e

Browse files
warning cleanup
1 parent cddf2ed commit 916c90e

File tree

8 files changed

+25
-61
lines changed

8 files changed

+25
-61
lines changed

potato_flow

src/Potato/Flow/Vty/AppKbCmd.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Potato.Flow.Vty.AppKbCmd where
22

33
import Relude
44

5-
import Potato.Flow
65
import Potato.Reflex.Vty.Helpers
76

87
import Reflex

src/Potato/Flow/Vty/Canvas.hs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@ module Potato.Flow.Vty.Canvas (
1111
import Relude
1212

1313
import Potato.Flow
14-
import Potato.Flow.Controller
15-
import Potato.Flow.Controller.Handler
16-
import Potato.Flow.Math
1714
import Potato.Flow.Vty.Input
1815
import Potato.Reflex.Vty.Helpers
19-
import Potato.Reflex.Vty.Widget
20-
import Reflex.Potato.Helpers
2116
import Potato.Flow.Vty.PotatoReader
2217

23-
import Control.Lens
24-
import qualified Data.IntMap.Strict as IM
25-
import Data.These
2618
import qualified Data.Text as T
2719
import qualified Data.List.Index as L
2820
import Data.Tuple.Extra (thd3)
@@ -34,7 +26,7 @@ import Reflex.Vty
3426

3527
-- alternative text rendering methods that don't show spaces
3628
textNoRenderSpaces
37-
:: (Reflex t, Monad m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m)
29+
:: (HasDisplayRegion t m, HasImageWriter t m, HasTheme t m)
3830
=> Behavior t Text
3931
-> m ()
4032
textNoRenderSpaces t = do
@@ -54,19 +46,14 @@ textNoRenderSpaces t = do
5446
(x,n):xs -> (0, (c:x,n):xs)
5547
-- first character case
5648
[] -> (0, [([c], 0)])
57-
makeimages theme =
49+
makeimages th =
5850
-- (\x -> traceShow (length x) x) .
5951
join
6052
. L.imap (\i -> fmap (V.translateY i)) -- for each line, offset the image vertically
61-
. fmap (fmap (\(t,offset) -> V.translateX offset $ V.string theme (reverse t))) -- for each chunk and offset, convert to image
53+
. fmap (fmap (\(txt,offset) -> V.translateX offset $ V.string th (reverse txt))) -- for each chunk and offset, convert to image
6254
. fmap (thd3 . foldl' foldlinefn (0,0,[]) . T.unpack) -- for each line, split into chunks with offset
6355
. T.split (=='\n') -- split into lines
6456

65-
66-
-- TODO this needs to come from Potato.Flow
67-
defaultCanvasLBox :: LBox
68-
defaultCanvasLBox = LBox (V2 0 0) (V2 100 50)
69-
7057
lBox_to_region :: LBox -> Region
7158
lBox_to_region (LBox (V2 x y) (V2 w h)) = Region x y w h
7259

@@ -76,11 +63,13 @@ region_to_lBox (Region x y w h) = (LBox (V2 x y) (V2 w h))
7663
dynLBox_to_dynRegion :: (Reflex t) => Dynamic t LBox -> Dynamic t Region
7764
dynLBox_to_dynRegion dlb = ffor dlb $ lBox_to_region
7865

66+
{- DELETE ME
7967
translate_dynRegion :: (Reflex t) => Dynamic t XY -> Dynamic t Region -> Dynamic t Region
8068
translate_dynRegion dpos dr = ffor2 dpos dr $ \(V2 x y) region -> region {
8169
_region_left = _region_left region + x
8270
, _region_top = _region_top region + y
8371
}
72+
-}
8473

8574
pan_lBox :: XY -> LBox -> LBox
8675
pan_lBox pan (LBox p s) = LBox (p+pan) s
@@ -144,6 +133,7 @@ holdCanvasWidget CanvasWidgetConfig {..} = mdo
144133
localTheme (const (fmap _potatoStyle_softSelected potatostylebeh)) $ do
145134
fill (constant ' ')
146135
simpleList oobRegions renderRegion
136+
return ()
147137

148138
-- 2. render the canvas region
149139
renderRegion trueRegion
@@ -152,6 +142,7 @@ holdCanvasWidget CanvasWidgetConfig {..} = mdo
152142
-- TODO use correct theme
153143
localTheme (const (fmap _potatoStyle_selected potatostylebeh)) $ do
154144
textNoRenderSpaces . current . ffor3 _canvasWidgetConfig_pan screenRegion _canvasWidgetConfig_renderedSelection $ debugRenderRegionFn
145+
return ()
155146

156147

157148

src/Potato/Flow/Vty/Common.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ module Potato.Flow.Vty.Common (
1313
import Relude
1414
import qualified Relude.Unsafe as Unsafe
1515

16-
import Potato.Flow.Controller
1716
import Potato.Flow.Vty.Attrs
18-
import Potato.Reflex.Vty.Helpers
1917
import Potato.Reflex.Vty.Widget
2018

2119
import Control.Monad.Fix
@@ -29,6 +27,8 @@ import Reflex
2927
import Reflex.Vty
3028

3129

30+
31+
3232
ffilterButtonIndex :: (Reflex t) => Int -> Event t Int -> Event t ()
3333
ffilterButtonIndex i = fmapMaybe (\i' -> if i == i' then Just () else Nothing)
3434

@@ -39,14 +39,14 @@ maximumlist = foldr (\x y ->if x >= y then x else y) (-1)
3939
simpleDrag :: (Reflex t, MonadHold t m, MonadFix m, HasInput t m) => V.Button -> m (Event t ((Int, Int), (Int, Int)))
4040
simpleDrag btn = do
4141
dragEv <- drag2 btn
42-
return $ flip push dragEv $ \d@(Drag2 (fromX, fromY) (toX, toY) _ mods ds) -> do
42+
return $ flip push dragEv $ \(Drag2 (fromX, fromY) (toX, toY) _ _ ds) -> do
4343
return $ if ds == DragEnd
4444
then Just $ ((fromX, fromY), (toX, toY))
4545
else Nothing
4646

4747

4848
-- | option to pass in height is a hack to work around circular dependency issues as when using Layout, displayWidth may be dependent on returned dynamic height
49-
buttonList :: forall t m. (Reflex t, MonadFix m, MonadHold t m, MonadNodeId m, HasDisplayRegion t m, HasImageWriter t m, HasInput t m, HasTheme t m)
49+
buttonList :: forall t m. (MonadFix m, MonadHold t m, HasDisplayRegion t m, HasImageWriter t m, HasInput t m, HasTheme t m)
5050
=> Dynamic t [Text] -- ^ list of button contents
5151
-> Maybe (Dynamic t Int) -- ^ optional width (displayWidth is used if Nothing)
5252
-> m (Event t Int, Dynamic t Int) -- ^ (event when button is clicked, height)
@@ -129,7 +129,7 @@ radioListSimple :: forall t m. (Reflex t, MonadFix m, MonadHold t m, MonadNodeId
129129
-> m (Dynamic t Int) -- ^ which radio is selected
130130
radioListSimple initial buttons = mdo
131131
(radioEvs,_) <- radioList (constDyn buttons) radioDyn Nothing
132-
radioDyn <- holdDyn [0] $ fmap (\x->[x]) radioEvs
132+
radioDyn <- holdDyn [initial] $ fmap (\x->[x]) radioEvs
133133
return $ fmap (Unsafe.head) radioDyn
134134

135135

@@ -138,7 +138,7 @@ radioListSimple initial buttons = mdo
138138
-- | creates a check box "[x]" in upper left corner of region
139139
-- override style: does not modify state internally, instead state must be passed back in
140140
checkBox
141-
:: forall t m. (Reflex t, MonadFix m, MonadHold t m, MonadNodeId m, HasDisplayRegion t m, HasImageWriter t m, HasInput t m, HasTheme t m)
141+
:: forall t m. (Reflex t, MonadFix m, HasDisplayRegion t m, HasImageWriter t m, HasInput t m, HasTheme t m)
142142
=> Dynamic t Bool
143143
-> m (Event t Bool)
144144
checkBox stateDyn = do

src/Potato/Flow/Vty/Info.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@ module Potato.Flow.Vty.Info (
1010
import Relude
1111

1212
import Potato.Flow
13-
import Potato.Flow.Vty.Common
1413
import Potato.Reflex.Vty.Helpers
1514

16-
import Control.Monad.Fix
17-
import Control.Monad.NodeId
18-
import qualified Data.Sequence as Seq
19-
import qualified Data.Text as T
20-
21-
import qualified Graphics.Vty as V
2215
import Reflex
2316
import Reflex.Network
2417
import Reflex.Vty

src/Potato/Flow/Vty/Tools.hs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@ module Potato.Flow.Vty.Tools (
1111
import Relude
1212

1313
import Potato.Flow.Controller
14-
import Potato.Flow.Vty.Attrs
1514
import Potato.Flow.Vty.Common
1615
import Potato.Reflex.Vty.Helpers
1716

1817
import Control.Monad.Fix
1918
import Control.Monad.NodeId
20-
import qualified Data.List.Index as L
21-
import qualified Data.Text as T
2219

23-
import qualified Graphics.Vty as V
2420
import Reflex
25-
import Reflex.Vty
2621

2722

2823
data ToolWidgetConfig t = ToolWidgetConfig {
@@ -36,11 +31,11 @@ data ToolWidget t = ToolWidget {
3631
}
3732

3833

39-
onlyIfBeh :: (Reflex t) => Event t a -> Behavior t Bool -> Event t a
40-
onlyIfBeh ev beh = fmapMaybe (\(b,e) -> if b then Just e else Nothing) $ attach beh ev
34+
--onlyIfBeh :: (Reflex t) => Event t a -> Behavior t Bool -> Event t a
35+
--onlyIfBeh ev beh = fmapMaybe (\(b,e) -> if b then Just e else Nothing) $ attach beh ev
4136

4237

43-
holdToolsWidget :: forall t m. (PostBuild t m, MonadHold t m, MonadFix m, MonadNodeId m, MonadWidget t m)
38+
holdToolsWidget :: forall t m. (PostBuild t m, MonadWidget t m)
4439
=> ToolWidgetConfig t
4540
-> m (ToolWidget t)
4641
holdToolsWidget ToolWidgetConfig {..} = mdo
@@ -55,16 +50,6 @@ holdToolsWidget ToolWidgetConfig {..} = mdo
5550
textareaB = void $ ffilter (==5) radioEvs
5651

5752
let
58-
-- TODO DELETE, we don't do key press anymore
59-
{-
60-
allowKB = constant True
61-
keyPressEv' k = (flip fmapMaybe) (_pFWidgetCtx_ev_input _toolWidgetConfig_pfctx) $ \case
62-
V.EvKey (V.KChar k') [] | k' == k -> Just ()
63-
_ -> Nothing
64-
keyPressEv k = onlyIfBeh (keyPressEv' k) allowKB
65-
-}
66-
keyPressEv k = never
67-
6853
setTool = leftmost
6954
[Tool_Select <$ leftmost [selectB]
7055
, Tool_Pan <$ leftmost [panB]

src/Potato/Reflex/Vty/Helpers.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ type MonadWidget t m = (Reflex t, MonadHold t m, MonadFix m, NotReady t m, Adjus
4949

5050
type MonadLayoutWidget t m = (MonadWidget t m, HasFocus t m, HasLayout t m)
5151

52-
debugFocus :: (Reflex t, Monad m, HasFocusReader t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => m ()
52+
debugFocus :: (HasFocusReader t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => m ()
5353
debugFocus = do
5454
f <- focus
5555
text $ T.pack . show <$> current f
5656

57-
debugInput :: (Reflex t, MonadHold t m, HasInput t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => m ()
57+
debugInput :: (MonadHold t m, HasInput t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => m ()
5858
debugInput = do
5959
lastEvent <- hold "No event yet" . fmap show =<< input
6060
text $ T.pack <$> lastEvent
6161

62-
debugSize :: (Reflex t, MonadHold t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => m ()
62+
debugSize :: (MonadHold t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => m ()
6363
debugSize = do
6464
ldw <- displayWidth
6565
ldh <- displayHeight
6666
let combine w h = "w: " <> show w <> " h: " <> show h
6767
text $ liftA2 combine (current ldw) (current ldh)
6868

69-
dragTest :: (Reflex t, MonadHold t m, MonadFix m, HasDisplayRegion t m, HasImageWriter t m, HasInput t m, HasTheme t m) => m ()
69+
dragTest :: (MonadHold t m, MonadFix m, HasDisplayRegion t m, HasImageWriter t m, HasInput t m, HasTheme t m) => m ()
7070
dragTest = do
7171
lastEvent <- hold "No event yet" . fmap show =<< drag V.BLeft
7272
text $ T.pack <$> lastEvent
@@ -78,12 +78,12 @@ fmapLabelShow :: (Functor f, Show a) => Text -> f a -> f Text
7878
fmapLabelShow t = fmap (\x -> t <> ": " <> show x)
7979

8080
-- TODO rename to debugStreamEv
81-
debugStream :: (Reflex t, MonadHold t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => [Event t Text] -> m ()
81+
debugStream :: (MonadHold t m, HasDisplayRegion t m, HasImageWriter t m, HasTheme t m) => [Event t Text] -> m ()
8282
debugStream evs = do
8383
t <- holdDyn "" $ mergeWith (\a b -> a <> "\n" <> b) evs
8484
richText richTextConfig_simpleForeColorAttr (current t)
8585

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

8989
countEv :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Dynamic t Int)

src/Potato/Reflex/Vty/Widget.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ module Potato.Reflex.Vty.Widget
2727

2828
import Prelude
2929

30-
import Control.Applicative (liftA2)
31-
import Graphics.Vty (Image)
3230
import qualified Graphics.Vty as V
3331

3432
import Reflex
3533
import Reflex.Class ()
36-
import Reflex.Host.Class (MonadReflexCreateTrigger)
37-
import Reflex.Vty.Host
3834
import Reflex.Vty.Widget
3935
import Reflex.Vty.Widget.Input.Mouse
4036

@@ -62,7 +58,7 @@ singleClick btn = do
6258
withinBounds (Drag2 (fromX, fromY) (toX, toY) _ _ _) = fromX == toX && fromY == toY
6359
dragEv <- drag2 btn
6460
didStayOnDyn <- foldDyn (const . withinBounds) False dragEv
65-
return $ flip push dragEv $ \d@(Drag2 (fromX, fromY) (toX, toY) _ mods ds) -> do
61+
return $ flip push dragEv $ \d@(Drag2 (fromX, fromY) _ _ mods ds) -> do
6662
didStayOn <- sample . current $ didStayOnDyn
6763
return $ if ds == DragEnd && withinBounds d
6864
then Just $ SingleClick btn (fromX, fromY) mods (not didStayOn)
@@ -80,7 +76,7 @@ integralFractionalDivide n d = fromIntegral n / fromIntegral d
8076
-- | A split of the available space into two parts with a draggable separator.
8177
-- Starts with half the space allocated to each, and the first pane has focus.
8278
-- Clicking in a pane switches focus.
83-
splitHDrag :: (Reflex t, MonadFix m, MonadHold t m, MonadNodeId m, HasDisplayRegion t m, HasInput t m, HasImageWriter t m, HasFocusReader t m)
79+
splitHDrag :: (Reflex t, MonadFix m, MonadHold t m, HasDisplayRegion t m, HasInput t m, HasImageWriter t m, HasFocusReader t m)
8480
=> Int -- ^ initial width of left panel
8581
-> m ()
8682
-> m a

0 commit comments

Comments
 (0)