Simplify terminals, move towards using tries for commands
This commit is contained in:
+16
-16
@@ -40,8 +40,8 @@ basicTerminal =
|
||||
{ _tmDisplayedLines = []
|
||||
, _tmFutureLines = []
|
||||
-- , _tmTitle = "TERMINAL"
|
||||
, _tmScrollCommands = [quitCommand]
|
||||
, _tmWriteCommands = [helpCommand, commandsCommand]
|
||||
, _tmScrollCommands = [helpCommand,commandsCommand,quitCommand]
|
||||
-- , _tmWriteCommands = [helpCommand, commandsCommand]
|
||||
, _tmBootLines = connectionBlurb
|
||||
, _tmDeathEffect = TmWdWdDoDeathTriggers
|
||||
}
|
||||
@@ -49,11 +49,11 @@ basicTerminal =
|
||||
connectionBlurbLines :: [TerminalLine] -> [TerminalLine]
|
||||
connectionBlurbLines tls =
|
||||
[ termSoundLine computerBeepingS
|
||||
, TerminalLineDisplay 0 (TerminalLineConst "LOADING TEXT INTERFACE..." termTextColor)
|
||||
, TLine 0 [TerminalLineConst "LOADING TEXT INTERFACE..." termTextColor] TmWdId
|
||||
]
|
||||
++ tls
|
||||
++ [ TerminalLineDisplay 10 (TerminalLineConst "READY FOR INPUT" termTextColor)]
|
||||
++ [TerminalLineEffect 0 (TmTmSetStatus (TerminalTextInput ""))]
|
||||
++ [ TLine 10 [TerminalLineConst "READY FOR INPUT" termTextColor] (TmTmSetStatus (TerminalTextInput "" 0))]
|
||||
-- ++ [TerminalLineEffect 0 (TmTmSetStatus (TerminalTextInput "" 0))]
|
||||
|
||||
quitCommand :: TerminalCommand
|
||||
quitCommand =
|
||||
@@ -61,7 +61,7 @@ quitCommand =
|
||||
{ _tcString = "QUIT"
|
||||
, _tcAlias = ["Q", "EXIT", "X", "SHUTDOWN", ""]
|
||||
, _tcHelp = "Disconnects the terminal."
|
||||
, _tcEffect = TerminalCommandArguments $ NoArguments [TerminalLineEffect 0 TmWdWdDisconnectTerminal]
|
||||
, _tcEffect = TerminalCommandArguments $ NoArguments [TLine 0 [] TmWdWdDisconnectTerminal]
|
||||
}
|
||||
|
||||
helpCommand :: TerminalCommand
|
||||
@@ -104,13 +104,13 @@ connectionBlurb :: [TerminalLine]
|
||||
connectionBlurb = connectionBlurbLines []
|
||||
|
||||
termSoundLine :: SoundID -> TerminalLine
|
||||
termSoundLine sid = TerminalLineEffect 0 (TmWdWdTermSound sid)
|
||||
termSoundLine sid = TLine 0 [] (TmWdWdTermSound sid)
|
||||
|
||||
termTextColor :: Color
|
||||
termTextColor = greyN 0.9
|
||||
|
||||
getCommands :: Terminal -> [TerminalCommand]
|
||||
getCommands tm = _tmScrollCommands tm ++ _tmWriteCommands tm
|
||||
getCommands tm = _tmScrollCommands tm -- ++ _tmWriteCommands tm
|
||||
|
||||
makeTermLine :: String -> TerminalLine
|
||||
makeTermLine = makeColorTermLine termTextColor
|
||||
@@ -122,7 +122,7 @@ makeColorTermPara :: Color -> String -> [TerminalLine]
|
||||
makeColorTermPara col = map (makeColorTermLine col) . makeParagraph 55
|
||||
|
||||
makeColorTermLine :: Color -> String -> TerminalLine
|
||||
makeColorTermLine col str = TerminalLineDisplay 1 $ TerminalLineConst str col
|
||||
makeColorTermLine col str = TLine 1 [TerminalLineConst str col] TmWdId
|
||||
|
||||
commandColor :: Color
|
||||
commandColor = yellow
|
||||
@@ -140,7 +140,7 @@ doTerminalCommandEffect tce = case tce of
|
||||
( makeTermLine "Available commands:" :
|
||||
makeColorTermPara commandColor (unwords (map _tcString $ getCommands tm))
|
||||
)
|
||||
TerminalCommandEffectSingleCommand eff followingLines -> \_ _ -> NoArguments $ TerminalLineEffect 0 (TmWdWdfromWdWd eff) : map makeTermLine followingLines
|
||||
TerminalCommandEffectSingleCommand eff followingLines -> \_ _ -> NoArguments $ TLine 0 [] (TmWdWdfromWdWd eff) : map makeTermLine followingLines
|
||||
TerminalCommandEffectNone -> \_ _ -> NoArguments []
|
||||
|
||||
argumentHelp :: TerminalCommand -> Terminal -> World -> (String, Maybe [String])
|
||||
@@ -214,7 +214,7 @@ disconnectTerminal tm =
|
||||
(cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff)
|
||||
. exitTerminalSubInv
|
||||
. ( cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines
|
||||
.~ [TerminalLineEffect 0 TmTmClearDisplayedLines]
|
||||
.~ [TLine 0 [] TmTmClearDisplayedLines]
|
||||
)
|
||||
|
||||
exitTerminalSubInv :: World -> World
|
||||
@@ -243,7 +243,7 @@ damageCodeCommand =
|
||||
togglesToEffects :: Terminal -> M.Map String [TerminalLine]
|
||||
togglesToEffects = fmap f . _tmToggles
|
||||
where
|
||||
f tt = [TerminalLineEffect 0 $ TmWdWdfromWdWd $ WdWdNegateTrig (_ttTriggerID tt)]
|
||||
f tt = [TLine 0 [] $ TmWdWdfromWdWd $ WdWdNegateTrig (_ttTriggerID tt)]
|
||||
|
||||
simpleTermMessage :: [String] -> Terminal
|
||||
simpleTermMessage strs = defaultTerminal & tmBootLines .~ map makeTermLine strs
|
||||
@@ -257,10 +257,10 @@ commandFutureLines s tm w = fromMaybe [errline "^ Invalid command"] $ do
|
||||
OneArgument argtype m ->
|
||||
let setpartial
|
||||
| null (_tmPartialCommand tm) =
|
||||
TerminalLineEffect 0 (TmTmSetPartialCommand (Just command)) :
|
||||
TLine 0 [] (TmTmSetPartialCommand (Just command)) :
|
||||
makeTermPara ("Expects " ++ argtype ++ " as an argument")
|
||||
| otherwise =
|
||||
TerminalLineEffect 0 (TmTmSetPartialCommand Nothing) :
|
||||
TLine 0 [] (TmTmSetPartialCommand Nothing) :
|
||||
makeTermPara "No argument input, cancelling"
|
||||
in Just $
|
||||
fromMaybe setpartial $
|
||||
@@ -284,7 +284,7 @@ terminalReturnEffect tmid w = fromMaybe w $ do
|
||||
runTerminalString :: String -> Terminal -> World -> World
|
||||
runTerminalString s tm w =
|
||||
w & cWorld . lWorld . terminals . ix (_tmID tm)
|
||||
%~ ( (tmInput .~ TerminalInput{ _tiSel = (0, 0)})
|
||||
. (tmFutureLines ++.~ commandFutureLines s tm w)
|
||||
%~ ( --(tmInput .~ TerminalInput{ _tiSel = (0, 0)})
|
||||
(tmFutureLines ++.~ commandFutureLines s tm w)
|
||||
. (tmCommandHistory %~ take 10 . (s :))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user