package miaou-core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Miaou_internals.Focus_containerSource

Focus container: GADT-based heterogeneous widget container.

Holds a Focus_ring.t and a list of existentially packed widget slots. Tab/Shift+Tab cycle focus; other keys are routed to the focused widget automatically.

  let c = FC.create [
    FC.slot "enable" checkbox_ops (Checkbox_widget.create ());
    FC.slot "name"   textbox_ops  (Textbox_widget.create ());
    FC.slot "go"     button_ops   (Button_widget.create ~label:"Go"
                                     ~on_click:ignore ());
  ]
  let c', result = FC.on_key c ~key:"Tab"
Sourcetype 'a widget_ops = {
  1. render : 'a -> focus:bool -> string;
  2. on_key : 'a -> key:string -> 'a * Miaou_interfaces.Key_event.result;
}

Widget operations record -- uniform interface for any widget type.

Sourcetype 'a widget_ops_legacy = {
  1. render : 'a -> focus:bool -> string;
  2. handle_key : 'a -> key:string -> 'a * [ `Handled | `Bubble ];
}
  • deprecated

    Legacy widget ops with polymorphic variant result.

Sourcetype packed_slot

Existentially packed widget slot.

Sourceval slot : string -> 'a widget_ops -> 'a -> packed_slot

Create a named slot.

Sourcetype t

The container type.

Sourceval create : packed_slot list -> t

Create from a list of slots. Focus ring built from slot IDs.

Sourceval on_key : t -> key:string -> t * Miaou_interfaces.Key_event.result

Handle a key. Tab/Shift+Tab cycle focus; other keys route to the focused widget. Returns Key_event.result.

Sourceval handle_key : t -> key:string -> t * [ `Handled | `Bubble ]
  • deprecated

    Use on_key instead. Returns polymorphic variant for compat.

Sourceval render_all : t -> (string * bool * string) list

Render all widgets: (id, focused, rendered_string) in order.

Sourceval render_focused : t -> (string * string) option

Render only the focused widget.

Sourceval focused_id : t -> string option

Current focused slot ID.

Sourceval focus : t -> string -> t

Focus a slot by ID.

Sourceval ring : t -> Focus_ring.t

Access the underlying focus ring (for scope nesting).

Sourceval set_ring : t -> Focus_ring.t -> t

Replace the focus ring.

Sourceval count : t -> int

Number of slots.

Type-safe extraction via witness

Sourcetype 'a witness
Sourceval witness : unit -> 'a witness
Sourceval slot_w : string -> 'a widget_ops -> 'a -> 'a witness -> packed_slot
Sourceval get : t -> string -> 'a witness -> 'a option
Sourceval set : t -> string -> 'a witness -> 'a -> t

Adapter constructors

Sourceval ops : render:('a -> focus:bool -> string) -> on_key:('a -> key:string -> 'a * Miaou_interfaces.Key_event.result) -> 'a widget_ops

Create widget_ops from render and on_key functions.

Sourceval ops_simple : render:('a -> focus:bool -> string) -> handle_key:('a -> key:string -> 'a) -> 'a widget_ops
  • deprecated

    For widgets with handle_key : t -> key:string -> t (always bubbles).

Sourceval ops_bool : render:('a -> focus:bool -> string) -> handle_key:('a -> key:string -> 'a * bool) -> 'a widget_ops
  • deprecated

    For widgets with handle_key : t -> key:string -> t * bool.

Sourceval ops_of_legacy : 'a widget_ops_legacy -> 'a widget_ops

Adapter: wrap legacy handle_key returning polymorphic variant.