Work on press-continue terminal prompts

This commit is contained in:
2025-08-19 11:08:54 +01:00
parent e7b66b4fa4
commit 2f4fcb42e5
14 changed files with 84 additions and 71 deletions
+13 -18
View File
@@ -1,12 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Terminal (
-- doTerminalCommandEffect,
makeTermLine,
-- commandFutureLines,
-- quitCommand,
-- helpCommand,
-- commandsCommand,
connectionBlurbLines,
disconnectTerminal,
textTerminal,
@@ -21,6 +16,7 @@ module Dodge.Terminal (
makeColorTermPara,
commandColor,
tabComplete,
tlSetStatus,
) where
--import Dodge.Data.WorldEffect
@@ -158,9 +154,7 @@ helpCommand = PTE.singleton "HELP" (fmap makeTermPara helpStrings)
helpStrings :: PTE.TrieMap Char String
helpStrings =
PTE.fromList
[ ("", "THIS TERMINAL PROCESSES TEXT INPUT. USE [TAB] FOR AVAILABLE COMMANDS AND AUTOCOMPLETE.")
, ("HELP", "BASIC HELP. ACCEPTS A COMMAND AS AN ARGUMENT.")
, ("QUIT", "SHUTDOWN TERMINAL.")
[ ("", "THIS TERMINAL PROCESSES KEYBOARD INPUT. USE [RETURN] OR [LMB] TO REGISTER YOUR INPUT. AVAILABLE COMMANDS CAN BE SCROLLED THROUGH, HOLD [RMB] TO SCROLL THROUGH ARGUMENTS. USE [TAB] FOR AUTOCOMPLETE.")
]
quitCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
@@ -169,6 +163,9 @@ quitCommand = PTE.singleton "QUIT" (PTE.singleton "" [TLine 0 [] TmWdWdDisconnec
makeTermLine :: String -> TerminalLine
makeTermLine = makeColorTermLine termTextColor
tlSetStatus :: TerminalStatus -> [TerminalLine]
tlSetStatus x = [TLine 1 [] $ TmTmSetStatus x]
makeTermPara :: String -> [TerminalLine]
makeTermPara = makeColorTermPara termTextColor
@@ -192,12 +189,13 @@ tabComplete s' tm = case PTE.lookup s $ getCommands tm of
a = fromMaybe "" $ ss ^? ix 1
f y m' = case fmap fst m' of
[] -> tm
[x] -> tm & tmStatus .~ TerminalTextInput (y ++ x)
[x] -> tm & tmStatus . tiText .~ (y ++ x)
xs ->
tm & tmFutureLines
.~ makeColorTermPara
tm & tmStatus .~ TerminalLineRead
& tmFutureLines
.~ (makeColorTermPara
commandColor
(unwords xs)
(unwords xs) <> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s])
--doTerminalCommandEffect :: TerminalCommandEffect -> Terminal -> World -> EffectArguments
--doTerminalCommandEffect tce = case tce of
@@ -274,8 +272,7 @@ disconnectTerminal :: Terminal -> World -> World
disconnectTerminal tm =
(cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff)
. exitTerminalSubInv
. ( cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines
.~ [TLine 0 [] TmTmClearDisplayedLines]
. ( cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ []
)
exitTerminalSubInv :: World -> World
@@ -342,11 +339,9 @@ terminalReturnEffect tmid w = fromMaybe w $ do
runTerminalInput :: String -> Terminal -> World -> World
runTerminalInput s tm w =
w & cWorld . lWorld . terminals . ix (_tmID tm)
%~ ( --(tmInput .~ TerminalInput{ _tiSel = (0, 0)})
(tmFutureLines ++.~ ss)
%~ ( (tmFutureLines ++.~ ss <> [TLine 1 [] (TmTmSetStatus $ TerminalTextInput "")])
. (tmCommandHistory %~ take 10 . (s :))
. (tmStatus .~ TerminalTextInput "")
. (tmStatus .~ TerminalLineRead)
)
where
ss = fromMaybe [makeTermLine "ERROR: INPUT NOT RECOGNISED"] $ do