@@ -11,18 +11,10 @@ module Potato.Flow.Vty.Canvas (
1111import Relude
1212
1313import Potato.Flow
14- import Potato.Flow.Controller
15- import Potato.Flow.Controller.Handler
16- import Potato.Flow.Math
1714import Potato.Flow.Vty.Input
1815import Potato.Reflex.Vty.Helpers
19- import Potato.Reflex.Vty.Widget
20- import Reflex.Potato.Helpers
2116import Potato.Flow.Vty.PotatoReader
2217
23- import Control.Lens
24- import qualified Data.IntMap.Strict as IM
25- import Data.These
2618import qualified Data.Text as T
2719import qualified Data.List.Index as L
2820import Data.Tuple.Extra (thd3 )
@@ -34,7 +26,7 @@ import Reflex.Vty
3426
3527-- alternative text rendering methods that don't show spaces
3628textNoRenderSpaces
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 ()
4032textNoRenderSpaces 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-
7057lBox_to_region :: LBox -> Region
7158lBox_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))
7663dynLBox_to_dynRegion :: (Reflex t ) => Dynamic t LBox -> Dynamic t Region
7764dynLBox_to_dynRegion dlb = ffor dlb $ lBox_to_region
7865
66+ {- DELETE ME
7967translate_dynRegion :: (Reflex t) => Dynamic t XY -> Dynamic t Region -> Dynamic t Region
8068translate_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
8574pan_lBox :: XY -> LBox -> LBox
8675pan_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
0 commit comments