# Core

The core module defines a bunch of system-wide “constants” (some colors and PyGame event groups), the message classes for Oberon-style message passing, a “world” class that holds the main context for the system, and a mainloop class that manages the, uh, main loop (the PyGame event queue.)

`joy.vui.core.``ARROW_KEYS` = frozenset([273, 274, 275, 276])

  PyGame arrow key events.

`joy.vui.core.``AVAILABLE_TASK_EVENTS` = set([24, 25, 26, 27, 28, 29, 30, 31])

  Task IDs that have not been assigned to a task.

class `joy.vui.core.``CommandMessage`(sender, command)

  For commands, adds `command` field.

`joy.vui.core.``MOUSE_EVENTS` = frozenset([4, 5, 6])

  PyGame mouse events.

class `joy.vui.core.``Message`(sender)

  Message base class. Contains `sender` field.

class `joy.vui.core.``ModifyMessage`(sender, subject, **details)

  For when resources are modified, adds `subject` and `details` fields.

class `joy.vui.core.``OpenMessage`(sender, name)

  For when resources are modified, adds `name`, content_id``, `status`, and `traceback` fields.

class `joy.vui.core.``PersistMessage`(sender, content_id, **details)

  For when resources are modified, adds `content_id` and `details` fields.

class `joy.vui.core.``ShutdownMessage`(sender)

  Signals that the system is shutting down.

`joy.vui.core.``TASK_EVENTS` = (24, 25, 26, 27, 28, 29, 30, 31)

  Keep track of all possible task events.

class `joy.vui.core.``TheLoop`(display, clock)

  The main loop manages tasks and the PyGame event queue and framerate clock.

  `install_task`(F, milliseconds)

    Install a task to run every so many milliseconds.

  `loop`()

    The actual main loop machinery.

    Maintain a `running` flag, pump the PyGame event queue and handle the events (dispatching to the display), tick the clock.

    When the loop is exited (by clicking the window close button or pressing the `escape` key) it broadcasts a `ShutdownMessage`.

  `remove_task`(task_event_id)

    Remove an installed task.

  `run_task`(task_event_id)

    Give a task its time to shine.

class `joy.vui.core.``World`(stack_id, stack_holder, dictionary, notify, log)

  This object contains the system context, the stack, dictionary, a reference to the display broadcast method, and the log.

  `handle`(message)

    Deal with updates to the stack and commands.

`joy.vui.core.``open_viewer_on_string`(sender, content, notify)

  Helper function to open a text viewer on a string. Typically used to show tracebacks.

`joy.vui.core.``push`(sender, item, notify, stack_name='stack.pickle')

  Helper function to push an item onto the system stack with message.