This commit is contained in:
2022-06-07 20:39:52 +01:00
parent 956ee87168
commit 5a42e0b801
6 changed files with 30 additions and 18 deletions
+13 -13
View File
@@ -152,21 +152,18 @@ wheelEvent y w = case _hudElement $ _hud w of
where
updatetermsel tm = case tm ^? tmInput . tiSel of
Nothing -> tm & tmInput . tiSel .~ (0,0)
& tmInput . tiText %~ replacewith tm 0
Just (i,_) -> let newi = ((`mod` length (scrollCommands tm)) . subtract yi) i
in tm & tmInput . tiSel .~ (newi,0)
& tmInput . tiText %~ replacewith tm newi
Just (i,_) -> let newi = (i - yi) `mod` length (scrollCommands tm)
in tm & setInput newi 0 w
updatetermsubsel tm = case tm ^? tmInput . tiSel of
Nothing -> tm
Just (i,j) -> let newj = (j - yi) `mod` (1 + length (getArguments (scrollCommands tm !! i) tm w))
in tm & tmInput . tiSel .~ (i,newj)
& tmInput . tiText %~ replacewith' tm i newj w
replacewith tp newi _ = T.pack (_tcString (scrollCommands tp !! newi))
replacewith' tp i j w' _ = T.pack $ _tcString tc ++ " " ++ arg-- ++ ((_tcArguments tp) w !! j)
Nothing -> tm & tmInput . tiSel .~ (0,0)
Just (i,j) -> let newj = (j - yi) `mod` length (getArguments' (scrollCommands tm !! i) tm w)
in tm & setInput i newj w
setInput i j w' tm = tm
& tmInput . tiSel .~ (i,j)
& tmInput . tiText .~ T.pack (_tcString tc ++ " " ++ arg)
where
arg :: String
arg = ("": getArguments tc tp w' )!! j
tc = scrollCommands tp !! i
tc = scrollCommands tm !! i
arg = getArguments' tc tm w' !! j
numcombs = length $ combineItemListYou w
yi = round $ signum y
numLocs = (fst . IM.findMax $ _seenLocations w) + 1
@@ -174,6 +171,9 @@ wheelEvent y w = case _hudElement $ _hud w of
lbDown = ButtonLeft `S.member` _mouseButtons w
invKeyDown = ScancodeCapsLock `S.member` _keys w
getArguments' :: TerminalCommand -> Terminal -> World -> [String]
getArguments' tc tm = ("" :) . getArguments tc tm
getArguments :: TerminalCommand -> Terminal -> World -> [String]
getArguments tc tm w = case _tcEffect tc tm w of
NoArguments {} -> []