Make selection cursors use selection item width

This commit is contained in:
2024-11-26 22:49:54 +00:00
parent f12c390778
commit 2b969f6530
9 changed files with 128 additions and 126 deletions
+15 -10
View File
@@ -67,14 +67,16 @@ makeSelectionListPictures = concatMap f
where
f si = map (color (_siColor si) . text) $ _siPictures si
-- note this does not take into account any selectionsection indent
-- note this does not take into account any selectionsection indent, nor the LDP
-- selection width
drawCursorAt ::
Maybe Int ->
[SelectionItem a] ->
ListDisplayParams ->
Int ->
CursorDisplay ->
Picture
drawCursorAt mi lis ldps curs = fromMaybe mempty $ do
drawCursorAt mi lis ldps width curs = fromMaybe mempty $ do
i <- mi
selit <- lis !? i
return $
@@ -85,13 +87,14 @@ drawCursorAt mi lis ldps curs = fromMaybe mempty $ do
(sum . map _siHeight $ take i lis)
(_siOffX selit)
(_siColor selit)
(getLDPWidth ldps)
width
(_siHeight selit)
getLDPWidth :: ListDisplayParams -> Int
getLDPWidth ldps = case _ldpWidth ldps of
getLDPWidth :: ListDisplayParams -> Int -> Int -> IM.IntMap (SelectionSection a) -> Int
getLDPWidth ldps i j sss = case _ldpWidth ldps of
FixedSelectionWidth x -> x
_ -> 1
-- UseMaxSelectionItemWidth -> a
UseItemWidth -> fromMaybe 0 $ sss ^? ix i . ssItems . ix j . siWidth
drawListYoff :: Int -> [Picture] -> Picture
drawListYoff = drawListYgapScaleYoff 0 1
@@ -106,16 +109,17 @@ stackPicturesAtOff :: Int -> [Picture] -> Picture
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
selSecDrawCursorAt ::
Int ->
-- Int ->
ListDisplayParams ->
CursorDisplay ->
IM.IntMap (SelectionSection a) ->
(Int, Int) ->
Picture
selSecDrawCursorAt xsize ldp curs sss (i, j) = fold $ do
selSecDrawCursorAt ldp curs sss (i, j) = fold $ do
yint <- selSecYint i j sss
sindent <- sss ^? ix i . ssIndent
si <- sss ^? ix i . ssItems . ix j
let xsize = getLDPWidth ldp i j sss
return $
listCursorChooseBorderScale
(ldp ^. ldpVerticalGap)
@@ -128,13 +132,14 @@ selSecDrawCursorAt xsize ldp curs sss (i, j) = fold $ do
(_siHeight si)
selSecDrawCursor ::
Int ->
-- Int ->
ListDisplayParams ->
CursorDisplay ->
IM.IntMap (SelectionSection a) ->
Maybe (Int, Int) ->
Picture
selSecDrawCursor xsize ldp curs = maybe mempty . selSecDrawCursorAt xsize ldp curs
--selSecDrawCursor xsize ldp curs = maybe mempty . selSecDrawCursorAt xsize ldp curs
selSecDrawCursor ldp curs = maybe mempty . selSecDrawCursorAt ldp curs
-- displays a cursor that should match up to list text pictures
listCursorChooseBorderScale ::