Improve tab completion, cleanup

This commit is contained in:
2025-08-20 17:15:34 +01:00
parent 9de2a22001
commit 3936e1a386
4 changed files with 8 additions and 18 deletions
-1
View File
@@ -51,7 +51,6 @@ data TCom
| TCBase | TCBase
| TCDamageCommand | TCDamageCommand
| TCSensorInfo | TCSensorInfo
-- | TCToggles
data TmWdWd data TmWdWd
= TmWdId = TmWdId
-1
View File
@@ -42,7 +42,6 @@ addWarningTerminal str outplid = (rmName .++~ "warningTerm-")
) )
termMessages trpl = termMessages trpl =
lineOutputTerminal (makeColorTermLine red "WARNING" : makeTermPara str) lineOutputTerminal (makeColorTermLine red "WARNING" : makeTermPara str)
-- & tmCommands .:~ TCToggles
& tmToggles .~ M.fromList & tmToggles .~ M.fromList
[("DOOR", TerminalToggle (fromJust $ _plMID trpl) (BlConst True))] [("DOOR", TerminalToggle (fromJust $ _plMID trpl) (BlConst True))]
+1 -2
View File
@@ -61,7 +61,6 @@ getCommand w tm = \case
TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z)) TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z))
TCBase -> helpCommand <> quitCommand <> toggleCommands tm TCBase -> helpCommand <> quitCommand <> toggleCommands tm
TCDamageCommand -> damageCodeCommand w TCDamageCommand -> damageCodeCommand w
-- TCToggles -> toggleCommand tm
TCSensorInfo -> sensorCommand w tm TCSensorInfo -> sensorCommand w tm
damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine]) damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
@@ -156,7 +155,7 @@ tabComplete s' w tm = case PTE.lookup s $ getCommands w tm of
.~ ( makeColorTermPara .~ ( makeColorTermPara
commandColor commandColor
(unwords xs) (unwords xs)
<> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s] <> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s']
) )
--damageCodeCommand :: TerminalCommand --damageCodeCommand :: TerminalCommand
+7 -14
View File
@@ -86,28 +86,21 @@ doDeathToggle (TerminalToggle trid f) = ix trid %~ doBlBl f
doTmWdWd :: TmWdWd -> Terminal -> World -> World doTmWdWd :: TmWdWd -> Terminal -> World -> World
doTmWdWd tmwdwd = case tmwdwd of doTmWdWd tmwdwd = case tmwdwd of
TmTmClearDisplayedLines -> \tm -> fromMaybe id $ do TmTmClearDisplayedLines -> \tm ->
tid <- tm ^? tmID cWorld . lWorld . terminals . ix (tm ^. tmID) . tmDisplayedLines .~ []
return $ cWorld . lWorld . terminals . ix tid . tmDisplayedLines .~ []
TmTmSetStatus x -> \tm -> cWorld . lWorld . terminals . ix (tm ^. tmID) . tmStatus .~ x TmTmSetStatus x -> \tm -> cWorld . lWorld . terminals . ix (tm ^. tmID) . tmStatus .~ x
TmWdId -> const id TmWdId -> const id
TmWdWdPowerDownTerminal -> powerDownTerminal TmWdWdPowerDownTerminal -> resetTerminal TerminalOff
TmWdWdDeactivateTerminal -> deactivateTerminal TmWdWdDeactivateTerminal -> resetTerminal TerminalDeactivated
TmWdWdTermSound sid -> \tm w -> TmWdWdTermSound sid -> \tm w ->
let tpos = fromMaybe 0 $ w ^? cWorld . lWorld . buttons . ix (_tmButtonID tm) . btPos let tpos = fromMaybe 0 $ w ^? cWorld . lWorld . buttons . ix (_tmButtonID tm) . btPos
in soundStart TerminalSound tpos sid Nothing w in soundStart TerminalSound tpos sid Nothing w
TmWdWdDoDeathTriggers -> doDeathTriggers TmWdWdDoDeathTriggers -> doDeathTriggers
TmWdWdfromWdWd f -> \_ -> doWdWd f TmWdWdfromWdWd f -> \_ -> doWdWd f
powerDownTerminal :: Terminal -> World -> World resetTerminal :: TerminalStatus -> Terminal -> World -> World
powerDownTerminal tm = resetTerminal x tm =
(cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff) (cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ x)
. (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ [])
. exitTerminalSubInv
deactivateTerminal :: Terminal -> World -> World
deactivateTerminal tm =
(cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalDeactivated)
. (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ []) . (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ [])
. exitTerminalSubInv . exitTerminalSubInv