Implement more scrolling arguments in terminal
This commit is contained in:
+18
-11
@@ -65,11 +65,12 @@ guardDisconnectedID tmid w w' = case w ^? cWorld . lWorld . terminals . ix tmid
|
||||
|
||||
terminalWheelEvent :: Int -> Int -> World -> World
|
||||
terminalWheelEvent yi tmid w
|
||||
-- | isJust $ w ^? cWorld . lWorld . terminals . ix tmid . tmPartialCommand . _Just = w
|
||||
| rbDown && inTermFocus w =
|
||||
guardDisconnectedID tmid w $
|
||||
w
|
||||
& cWorld . lWorld . terminals . ix tmid %~ updatetermsubsel
|
||||
| inTermFocus w =
|
||||
| inTermFocus w = guardDisconnectedID tmid w $
|
||||
w
|
||||
& cWorld . lWorld . terminals . ix tmid %~ updatetermsel
|
||||
| otherwise = w
|
||||
@@ -78,20 +79,21 @@ terminalWheelEvent yi tmid w
|
||||
updatetermsel tm = case tm ^? tmInput . tiSel of
|
||||
Nothing -> tm & tmInput . tiSel .~ (0, 0)
|
||||
Just (i, _) ->
|
||||
let newi = (i - yi) `mod` length (scrollCommands tm)
|
||||
in tm & setInput newi 0 w
|
||||
let newi = (i - yi) `mod` length (scrollCommandStrings w tm)
|
||||
in tm & setInput newi 0
|
||||
updatetermsubsel tm = case tm ^? tmInput . tiSel of
|
||||
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 =
|
||||
in tm & setInput i newj
|
||||
setInput i j tm =
|
||||
tm
|
||||
& tmInput . tiSel .~ (i, j)
|
||||
& tmInput . tiText .~ (_tcString tc ++ " " ++ arg)
|
||||
& tmInput . tiText .~ (comstr ++ arg)
|
||||
where
|
||||
comstr = scrollCommandStrings w tm !! i
|
||||
tc = scrollCommands tm !! i
|
||||
arg = getArguments' tc tm w' !! j
|
||||
arg = getArguments' tc tm w !! j
|
||||
|
||||
scrollRBOption :: Int -> RightButtonOptions -> RightButtonOptions
|
||||
scrollRBOption y w
|
||||
@@ -117,9 +119,14 @@ changeTweakParam mi i w = fromMaybe w $ do
|
||||
)
|
||||
|
||||
scrollCommands :: Terminal -> [TerminalCommand]
|
||||
scrollCommands tm
|
||||
| null $ _tmPartialCommand tm = (nullCommand :) $ _tmScrollCommands tm
|
||||
| otherwise = [nullCommand]
|
||||
scrollCommands tm = (nullCommand :) $ _tmScrollCommands tm
|
||||
-- | null $ _tmPartialCommand tm = (nullCommand :) $ _tmScrollCommands tm
|
||||
-- | otherwise = [nullCommand]
|
||||
|
||||
scrollCommandStrings :: World -> Terminal -> [String]
|
||||
scrollCommandStrings w tm = case tm ^? tmPartialCommand . _Just of
|
||||
Nothing -> map _tcString $ scrollCommands tm
|
||||
Just tc -> "": map tail (getArguments tc tm w)
|
||||
|
||||
getArguments' :: TerminalCommand -> Terminal -> World -> [String]
|
||||
getArguments' tc tm = ("" :) . getArguments tc tm
|
||||
@@ -136,4 +143,4 @@ nullCommand =
|
||||
getArguments :: TerminalCommand -> Terminal -> World -> [String]
|
||||
getArguments tc tm w = case doTerminalCommandEffect (_tcEffect tc) tm w of
|
||||
NoArguments{} -> []
|
||||
OneArgument _ m -> M.keys m
|
||||
OneArgument _ m -> map (' ':) $ M.keys m
|
||||
|
||||
Reference in New Issue
Block a user