celina/core/events

Search:
Group by:

Event handling

This module provides comprehensive event handling for keyboard input, including escape sequences and arrow keys for POSIX systems.

Types

Event = object
  case kind*: EventKind
  of Key:
    key*: KeyEvent
  of Mouse:
    mouse*: MouseEvent
  of Resize, Quit, Unknown:
    nil
EventKind = enum
  Key, Mouse, Resize, Quit, Unknown
MouseEvent = object
  kind*: MouseEventKind
  button*: MouseButton
  x*: int
  y*: int
  modifiers*: set[KeyModifier]

Procs

proc checkResize(): Option[Event] {....raises: [], tags: [], forbids: [].}
Check if a resize event occurred
proc hasInput(): bool {....raises: [], tags: [], forbids: [].}
Check if input is available without blocking
proc initSignalHandling() {....raises: [], tags: [], forbids: [].}
Initialize signal handling for terminal resize
proc pollEvents(timeoutMs: int): bool {....raises: [], tags: [], forbids: [].}
Poll for available events with a timeout Returns true if events are available, false if timeout occurred Similar to crossterm::event::poll()
proc pollKey(): Event {....raises: [Exception], tags: [RootEffect, ReadIOEffect],
                        forbids: [].}
Poll for a key event (non-blocking)
proc readKey(): Event {....raises: [Exception], tags: [RootEffect, ReadIOEffect],
                        forbids: [].}
Read a key event (blocking mode) Raises IOError if unable to read from stdin
proc readKeyInput(): Option[Event] {....raises: [IOError], tags: [ReadIOEffect],
                                     forbids: [].}
Read a single key input event (non-blocking) Returns none(Event) if no input is available or on error
proc waitForAnyKey(): bool {....raises: [Exception],
                             tags: [RootEffect, ReadIOEffect, TimeEffect],
                             forbids: [].}
Wait for any key press, return true if not quit
proc waitForKey(): Event {....raises: [Exception],
                           tags: [RootEffect, ReadIOEffect, TimeEffect],
                           forbids: [].}
Wait for a key press (blocking)