Allow for indentation of individual selection items

This commit is contained in:
2024-09-12 10:21:35 +01:00
parent eddb313ea1
commit 891fd0079c
8 changed files with 213 additions and 181 deletions
+5 -13
View File
@@ -12,6 +12,7 @@ import Dodge.Data.ComposedItem
--import TreeHelp
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Dodge.DoubleTree
type PCI = (ComposedItem, [ComposedItem], [ComposedItem])
@@ -107,15 +108,6 @@ joinItemsInList f xs = snd $ h (xs,[])
Nothing -> h (ys, (y:z:zs))
Just w -> h ((w:ys),zs)
headMap :: (a -> a) -> (a -> a) -> [a] -> [a]
headMap f g (x:xs) = f x : map g xs
headMap _ _ [] = []
lastMap :: (a -> a) -> (a -> a) -> [a] -> [a]
lastMap _ _ [] = []
lastMap f _ (x:[]) = [f x]
lastMap f g (x:xs) = g x : lastMap f g xs
indentDoubleTreeWith :: (a -> a) -> (a -> a) -> (a -> a) -> DoubleTree a -> DoubleTree a
indentDoubleTreeWith f g h (DT x l r) = DT x
(headMap (iDTL f g h) (iDTboth f g h) l)
@@ -151,10 +143,10 @@ invTree :: IM.IntMap Item -> [String]
invTree = concatMap (prettyDT (\(itm,_,_,_) -> show (_itType itm))) .
joinItemsInList joinItems . IM.elems . fmap (singleDT . baseCI)
indentInv :: IM.IntMap Item -> IM.IntMap String
indentInv = IM.fromList . zip [0..] .
reverse . concatMap (flattenDT .indentDoubleTreeWith (' ':) ('|':) ('+':) . fmap (const "")) .
joinItemsInList joinItems . IM.elems . fmap (singleDT . baseCI)
--indentInv :: IM.IntMap Item -> IM.IntMap String
--indentInv = IM.fromList . zip [0..] .
-- reverse . concatMap (flattenDT .indentDoubleTreeWith (' ':) ('|':) ('+':) . fmap (const "")) .
-- joinItemsInList joinItems . IM.elems . fmap (singleDT . baseCI)
--invLDT :: IM.IntMap Item -> [LabelDoubleTree ComposeLinkType PCI'']
invLDT :: IM.IntMap Item -> [LabelDoubleTree ComposeLinkType PCI'']