Work on toggle terminals

This commit is contained in:
2025-08-20 17:06:30 +01:00
parent 8557724fb5
commit 9de2a22001
4 changed files with 15 additions and 21 deletions
+11 -11
View File
@@ -9,7 +9,7 @@ module Dodge.Terminal (
sensorCommand,
makeColorTermLine,
makeTermPara,
toggleCommand,
-- toggleCommand,
terminalReturnEffect,
getCommands,
tabComplete,
@@ -59,9 +59,9 @@ getCommand :: World
-> Terminal -> TCom -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
getCommand w tm = \case
TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z))
TCBase -> helpCommand <> quitCommand
TCBase -> helpCommand <> quitCommand <> toggleCommands tm
TCDamageCommand -> damageCodeCommand w
TCToggles -> toggleCommand tm
-- TCToggles -> toggleCommand tm
TCSensorInfo -> sensorCommand w tm
damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
@@ -92,18 +92,18 @@ sensorCommand w tm = PTE.singleton "SENSOR" $ fromMaybe mempty $ do
]
toggleCommand :: Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
toggleCommand tm =
PTE.singleton "TOGGLE" $
PTE.fromList $
M.toList $ fmap f $ tm ^. tmToggles
toggleCommands :: Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
toggleCommands tm
| null ts = mempty
| otherwise = PTE.singleton "TOGGLE" $ PTE.fromList $ fmap f $ M.toList ts
where
f x =
ts = tm ^. tmToggles
f (s,x) = (s,
[ TLine
1
[TerminalLineConst "TOGGLE DONE!" termTextColor]
[TerminalLineConst (s ++ " TOGGLE DONE!") termTextColor]
(TmWdWdfromWdWd (WdWdNegateTrig $ x ^. ttTriggerID))
]
])
helpCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
helpCommand = PTE.singleton "HELP" (fmap makeTermPara helpStrings)