License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Swarm.TUI.Controller
Description
Event handlers for the TUI.
Synopsis
- handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- quitGame :: EventM Name AppState ()
- runFrameUI :: Bool -> EventM Name AppState ()
- ticksPerFrameCap :: Int
- runGameTickUI :: EventM Name AppState ()
- runBaseWebCode :: MonadState AppState m => Text -> m ()
- handleREPLEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- validateREPLForm :: AppState -> AppState
- adjReplHistIndex :: TimeDir -> AppState -> AppState
- data TimeDir
- handleInfoPanelEvent :: ViewportScroll Name -> BrickEvent Name AppEvent -> EventM Name AppState ()
Event handling
handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
The top-level event handler for the TUI.
quitGame :: 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 AppState m => Text -> m () Source #
handleREPLEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
Handle a user input event for the REPL.
validateREPLForm :: AppState -> AppState Source #
Validate the REPL input when it changes: see if it parses and typechecks, and set the color accordingly.
adjReplHistIndex :: TimeDir -> AppState -> AppState Source #
Update our current position in the REPL history.
Info panel
handleInfoPanelEvent :: ViewportScroll Name -> BrickEvent Name AppEvent -> EventM Name AppState () Source #
Handle user events in the info panel (just scrolling).
TODO: #2010 Finish porting Controller to KeyEventHandlers