Add file
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
module Dodge.Terminal.ReturnEffect
|
||||||
|
where
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
|
import Data.Maybe
|
||||||
|
import Dodge.Data.World
|
||||||
|
import LensHelp
|
||||||
|
import Dodge.Terminal -- this should be rethought
|
||||||
|
|
||||||
|
terminalReturnEffect :: Terminal -> World -> World
|
||||||
|
terminalReturnEffect tm w = fromMaybe w $ do
|
||||||
|
guard $ _tmStatus tm == TerminalReady
|
||||||
|
s <- w ^? cWorld . lWorld . terminals . ix (_tmID tm) . tmInput . tiText
|
||||||
|
let pc = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just
|
||||||
|
return $
|
||||||
|
runTerminalString (pc ++ s) tm $
|
||||||
|
w
|
||||||
|
& cWorld . lWorld . terminals . ix (_tmID tm) . tmPartialCommand .~ Nothing
|
||||||
|
& cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines .~
|
||||||
|
[makeTermLine (pc ++ "> " ++ s)]
|
||||||
|
|
||||||
|
runTerminalString :: String -> Terminal -> World -> World
|
||||||
|
runTerminalString s tm w =
|
||||||
|
w & cWorld . lWorld . terminals . ix (_tmID tm)
|
||||||
|
%~ ( (tmInput .~ TerminalInput mempty True (0, 0))
|
||||||
|
. (tmFutureLines ++.~ commandFutureLines s tm w)
|
||||||
|
. (tmCommandHistory %~ take 10 . (s :))
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user