License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.TUI.Controller
Description
Event handlers for the TUI.
Synopsis
- handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- quitGame :: Bool -> EventM Name AppState ()
- runFrameUI :: Bool -> EventM Name AppState ()
- ticksPerFrameCap :: Int
- runGameTickUI :: EventM Name AppState ()
- runBaseWebCode :: (MonadState ScenarioState m, MonadIO m) => Text -> (WebInvocationState -> IO ()) -> m ()
- handleREPLEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- validateREPLForm :: ScenarioState -> ScenarioState
- adjReplHistIndex :: TimeDir -> ScenarioState -> ScenarioState
- data TimeDir
- handleInfoPanelEvent :: ViewportScroll Name -> BrickEvent Name AppEvent -> EventM Name s ()
Event handling
handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
The top-level event handler for the TUI.
quitGame :: Bool -> EventM Name AppState () Source #
Quit a game.
- writes out the updated REPL history to a
.swarm_history
file - saves current scenario status (InProgress/Completed)
- advances the menu to the next scenario IF the current one was won
- returns to the previous menu
Handling Frame
events
runFrameUI :: Bool -> EventM Name AppState () Source #
Run the game for a single frame (i.e. screen redraw), then update the UI. Depending on how long it is taking to draw each frame, and how many ticks per second we are trying to achieve, this may involve stepping the game any number of ticks (including zero).
REPL panel
runBaseWebCode :: (MonadState ScenarioState m, MonadIO m) => Text -> (WebInvocationState -> IO ()) -> m () Source #
handleREPLEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
Handle a user input event for the REPL.
validateREPLForm :: ScenarioState -> ScenarioState Source #
Validate the REPL input when it changes: see if it parses and typechecks, and set the color accordingly.
adjReplHistIndex :: TimeDir -> ScenarioState -> ScenarioState Source #
Update our current position in the REPL history.
Info panel
handleInfoPanelEvent :: ViewportScroll Name -> BrickEvent Name AppEvent -> EventM Name s () Source #
Handle user events in the info panel (just scrolling).
TODO: #2010 Finish porting Controller to KeyEventHandlers