Simplify terminals, move towards using tries for commands
This commit is contained in:
+38
-37
@@ -123,32 +123,33 @@ moveCombineSel yi =
|
||||
return $ ci & ciSelection %~ scrollSelectionSections yi sss
|
||||
|
||||
terminalWheelEvent :: Int -> Int -> World -> World
|
||||
terminalWheelEvent yi tmid w
|
||||
--terminalWheelEvent yi tmid w
|
||||
terminalWheelEvent _ tmid w
|
||||
| w & has (input . mouseButtons . ix ButtonRight)
|
||||
, Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus =
|
||||
w & cWorld . lWorld . terminals . ix tmid %~ updatetermsubsel
|
||||
w -- & cWorld . lWorld . terminals . ix tmid %~ updatetermsubsel
|
||||
| Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus =
|
||||
w & cWorld . lWorld . terminals . ix tmid %~ updatetermsel
|
||||
w -- & cWorld . lWorld . terminals . ix tmid %~ updatetermsel
|
||||
| otherwise = w
|
||||
where
|
||||
updatetermsel tm = case tm ^? tmInput . tiSel of
|
||||
Nothing -> tm & tmInput . tiSel .~ (0, 0)
|
||||
Just (i, _) ->
|
||||
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
|
||||
setInput i j tm =
|
||||
tm
|
||||
& tmInput . tiSel .~ (i, j)
|
||||
& tmStatus . tiText .~ comstr ++ arg
|
||||
where
|
||||
comstr = scrollCommandStrings w tm !! i
|
||||
tc = scrollCommands tm !! i
|
||||
arg = getArguments' tc tm w !! j
|
||||
-- updatetermsel tm = case tm ^? tmInput . tiSel of
|
||||
-- Nothing -> tm & tmInput . tiSel .~ (0, 0)
|
||||
-- Just (i, _) ->
|
||||
-- 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
|
||||
-- setInput i j tm =
|
||||
-- tm
|
||||
-- & tmInput . tiSel .~ (i, j)
|
||||
-- & tmStatus . tiText .~ comstr ++ arg
|
||||
-- where
|
||||
-- comstr = scrollCommandStrings w tm !! i
|
||||
-- tc = scrollCommands tm !! i
|
||||
-- arg = getArguments' tc tm w !! j
|
||||
|
||||
scrollRBOption :: Int -> Int -> Int -> Int
|
||||
scrollRBOption dy ymax
|
||||
@@ -156,25 +157,25 @@ scrollRBOption dy ymax
|
||||
| dy > 0 = max 0 . subtract dy
|
||||
| otherwise = id
|
||||
|
||||
scrollCommands :: Terminal -> [TerminalCommand]
|
||||
scrollCommands = (nullCommand :) . _tmScrollCommands
|
||||
--scrollCommands :: Terminal -> [TerminalCommand]
|
||||
--scrollCommands = (nullCommand :) . _tmScrollCommands
|
||||
|
||||
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)
|
||||
--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
|
||||
--getArguments' :: TerminalCommand -> Terminal -> World -> [String]
|
||||
--getArguments' tc tm = ("" :) . getArguments tc tm
|
||||
|
||||
nullCommand :: TerminalCommand
|
||||
nullCommand =
|
||||
TerminalCommand
|
||||
{ _tcString = ""
|
||||
, _tcAlias = []
|
||||
, _tcHelp = ""
|
||||
, _tcEffect = TerminalCommandEffectNone -- \_ _ -> NoArguments []
|
||||
}
|
||||
--nullCommand :: TerminalCommand
|
||||
--nullCommand =
|
||||
-- TerminalCommand
|
||||
-- { _tcString = ""
|
||||
-- , _tcAlias = []
|
||||
-- , _tcHelp = ""
|
||||
-- , _tcEffect = TerminalCommandEffectNone -- \_ _ -> NoArguments []
|
||||
-- }
|
||||
|
||||
getArguments :: TerminalCommand -> Terminal -> World -> [String]
|
||||
getArguments tc tm w = case doTerminalCommandEffect (_tcEffect tc) tm w of
|
||||
|
||||
Reference in New Issue
Block a user