Mostly use String instead of Text

This commit is contained in:
2023-01-15 12:26:45 +00:00
parent 64b1c2761e
commit a50e2ff406
18 changed files with 50 additions and 65 deletions
+4 -18
View File
@@ -1,7 +1,7 @@
module Dodge.Render.List where
--import Data.Foldable
import Regex
import Dodge.SelectionList
import Data.Maybe
import Dodge.Base.WinScale
import Dodge.Base.Window
@@ -26,20 +26,9 @@ drawSelectionList ldps cfig sl =
<> drawSelectionCursor ldps cfig sl
makeSelectionListPictures :: SelectionList a -> [Picture]
makeSelectionListPictures sl = regex ++ concatMap f theitems
makeSelectionListPictures sl = concatMap f $ getShownItems sl
where
theitems = case sl ^. slRegex of
"" -> _slItems sl
str -> filter (doregex str) (_slItems sl)
doregex str = regexList str . _siPictures
regex = case sl ^. slRegex of
"" | not (sl ^. slRegexInput) -> []
str -> [text $ "SEARCH: " ++ str]
f si = map (color (_siColor si) . text) $ _siPictures si
--case sl ^. slSizeRestriction of
-- SelectionSizeRestriction {} -> concatMap (_siPictures . fst) $ _slShownItems sl
-- _ -> concatMap _siPictures $ _slItems sl
drawCursorAt :: ListDisplayParams -> Configuration -> Maybe Int -> [SelectionItem a] -> Picture
drawCursorAt ldps cfig mi lis = fromMaybe mempty $ do
@@ -57,16 +46,13 @@ drawCursorAt ldps cfig mi lis = fromMaybe mempty $ do
_ -> 1
drawSelectionCursor :: ListDisplayParams -> Configuration -> SelectionList a -> Picture
drawSelectionCursor ldps cfig sl = drawCursorAt ldps cfig (f $ sl ^. slSelPos) (g $ sl ^. slItems)
drawSelectionCursor ldps cfig sl = drawCursorAt ldps cfig (f $ sl ^. slSelPos) (getShownItems sl)
where
-- the following is quite hacky
f = case sl ^. slRegex of
_ | sl ^. slRegexInput -> const (Just 0)
"" | not (sl ^. slRegexInput) -> id
_ -> fmap (+1)
g (x:xs) = case sl ^. slRegex of
"" | not (sl ^. slRegexInput) -> (x:xs)
_ -> ((x & siHeight .~ 1) : x : xs)
g _ = []
-- given a list of pictures that are each the size of a "text" call, displays them as
-- a list on the screen