package miaou-core

  1. Overview
  2. Docs
Miaou core/widgets (no drivers, no SDL)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.5.2.tar.gz
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6

doc/miaou-core.internals/Miaou_internals/Key_handler_stack/index.html

Module Miaou_internals.Key_handler_stackSource

Pure hierarchical key handler stack (no global mutable state).

This module exposes an immutable stack value 't. All operations return a new stack instead of mutating hidden refs so the caller (driver) can thread it through its event loop state. This satisfies the requirement that the key stack is part of the overall application state.

Future extensions (e.g. actions pushing new frames) can be supported by enriching the action type to carry stack transformers. For now actions are simple callbacks (typically mutating page/modal state captured in closures).

Sourcetype action = unit -> unit
Sourcetype binding = {
  1. action : action option;
  2. help : string;
  3. display_only : bool;
}
Sourcetype frame = {
  1. id : int;
  2. delegate : bool;
    (*

    if true, unhandled keys bubble to next frame

    *)
  3. bindings : (string, binding) Hashtbl.t;
    (*

    key -> binding

    *)
}
Sourcetype t

opaque stack

Sourceval empty : t
Sourcetype handle = int

reference id for later pop

Sourceval push : t -> ?delegate:bool -> (string * binding) list -> t * handle
Sourceval pop : t -> handle -> t
Sourceval pop_top : t -> t
Sourceval clear : t -> t
Sourceval dispatch : t -> string -> bool * t

Dispatch a key, returning (consumed, new_stack). New stack is identical for now (no structural change) but reserved for future evolving actions.

Sourceval depth : t -> int
Sourceval top_keys : t -> string list
Sourceval top_bindings : t -> (string * string) list

Return (key, help) pairs for the current top frame, preserving no ordering guarantees (hash table fold).

Sourceval all_bindings : t -> (string * string) list

Return flattened list of (key, help) pairs from all frames top-first. Duplicates may appear if keys shadow lower frames.