Partial rethink of terminal text input
This commit is contained in:
+9
-16
@@ -18,7 +18,7 @@ module Dodge.Terminal (
|
||||
) where
|
||||
|
||||
import Color
|
||||
import Control.Monad
|
||||
--import Control.Monad
|
||||
import Data.Char
|
||||
import Data.Foldable
|
||||
import qualified Data.Map.Strict as M
|
||||
@@ -37,7 +37,7 @@ basicTerminal =
|
||||
defaultTerminal
|
||||
{ _tmDisplayedLines = []
|
||||
, _tmFutureLines = []
|
||||
, _tmTitle = "TERMINAL"
|
||||
-- , _tmTitle = "TERMINAL"
|
||||
, _tmScrollCommands = [quitCommand]
|
||||
, _tmWriteCommands = [helpCommand, commandsCommand]
|
||||
, _tmBootLines = connectionBlurb
|
||||
@@ -47,12 +47,11 @@ basicTerminal =
|
||||
connectionBlurbLines :: [TerminalLine] -> [TerminalLine]
|
||||
connectionBlurbLines tls =
|
||||
[ termSoundLine computerBeepingS
|
||||
, TerminalLineDisplay 0 (TerminalLineConst "Connecting" termTextColor)
|
||||
, TerminalLineDisplay 10 (TerminalLineConst "..." termTextColor)
|
||||
, TerminalLineDisplay 10 (TerminalLineConst "Connected" termTextColor)
|
||||
, TerminalLineDisplay 0 (TerminalLineConst "LOADING TEXT INTERFACE..." termTextColor)
|
||||
]
|
||||
++ tls
|
||||
++ [TerminalLineTerminalEffect 0 (TmTmSetStatus TerminalReady)]
|
||||
++ [ TerminalLineDisplay 10 (TerminalLineConst "READY FOR INPUT" termTextColor)]
|
||||
++ [TerminalLineTerminalEffect 0 (TmTmSetStatus (TerminalTextInput ""))]
|
||||
|
||||
quitCommand :: TerminalCommand
|
||||
quitCommand =
|
||||
@@ -100,13 +99,7 @@ commandsCommand =
|
||||
}
|
||||
|
||||
connectionBlurb :: [TerminalLine]
|
||||
connectionBlurb =
|
||||
[ termSoundLine computerBeepingS
|
||||
, TerminalLineDisplay 0 (TerminalLineConst "Connecting" termTextColor)
|
||||
, TerminalLineDisplay 10 (TerminalLineConst "..." termTextColor)
|
||||
, TerminalLineDisplay 10 (TerminalLineConst "Connected" termTextColor)
|
||||
, TerminalLineTerminalEffect 0 (TmTmSetStatus TerminalReady)
|
||||
]
|
||||
connectionBlurb = connectionBlurbLines []
|
||||
|
||||
termSoundLine :: SoundID -> TerminalLine
|
||||
termSoundLine sid = TerminalLineEffect 0 (TmWdWdTermSound sid)
|
||||
@@ -276,8 +269,8 @@ commandFutureLines s tm w = fromMaybe [errline "^ Invalid command"] $ do
|
||||
terminalReturnEffect :: Int -> World -> World
|
||||
terminalReturnEffect tmid w = fromMaybe w $ do
|
||||
tm <- w ^? cWorld . lWorld . terminals. ix tmid
|
||||
guard $ _tmStatus tm == TerminalReady
|
||||
s <- tm ^? tmInput . tiText
|
||||
-- guard $ _tmStatus tm == TerminalTextInput
|
||||
s <- tm ^? tmStatus . tiText
|
||||
let pc = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just . tcString
|
||||
return $
|
||||
runTerminalString (pc ++ s) tm $
|
||||
@@ -289,7 +282,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{_tiText = mempty, _tiSel = (0, 0)})
|
||||
%~ ( (tmInput .~ TerminalInput{ _tiSel = (0, 0)})
|
||||
. (tmFutureLines ++.~ commandFutureLines s tm w)
|
||||
. (tmCommandHistory %~ take 10 . (s :))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user