swarm-0.7.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellNone
LanguageHaskell2010

Swarm.TUI.Controller

Description

Event handlers for the TUI.

Synopsis

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).

runGameTickUI :: EventM Name AppState () Source #

Run the game for a single tick, and update the UI.

REPL panel

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.

data TimeDir Source #

Constructors

Newer 
Older 

Instances

Instances details
Show TimeDir Source # 
Instance details

Defined in Swarm.TUI.Model.Repl

Eq TimeDir Source # 
Instance details

Defined in Swarm.TUI.Model.Repl

Methods

(==) :: TimeDir -> TimeDir -> Bool #

(/=) :: TimeDir -> TimeDir -> Bool #

Ord TimeDir Source # 
Instance details

Defined in Swarm.TUI.Model.Repl

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