package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.internals/Miaou_internals/Focus_ring/index.html
Module Miaou_internals.Focus_ringSource
Named-slot focus ring with nested scope support.
A Focus_ring.t manages a flat ring of named slots with Tab/Shift+Tab cycling, named lookup, and per-slot enable/disable.
A Focus_ring.scope adds parent/child nesting: Tab stays within the active scope, Enter drills into a child scope, and Esc exits back to the parent.
(* Flat ring *)
let ring = Focus_ring.create ["search"; "filter"; "tree"] in
let focused = Focus_ring.is_focused ring "search" in
let ring, _ = Focus_ring.on_key ring ~key:"Tab" in
...
(* Nested scopes *)
let parent = Focus_ring.create ["sidebar"; "main"] in
let sidebar = Focus_ring.create ["search"; "filter"] in
let main = Focus_ring.create ["editor"; "preview"] in
let sc = Focus_ring.scope ~parent
~children:[("sidebar", sidebar); ("main", main)] in
let sc, _ = Focus_ring.on_scope_key sc ~key:"Enter" in
(* Now inside the sidebar child ring *)type slot = {id : string;(*Unique name within the ring.
*)focusable : bool;(*Whether this slot participates in Tab cycling.
*)
}A single focusable slot.
Create a focus ring from a list of slot IDs (all focusable by default).
Is the given slot ID currently focused? Useful in view functions.
Move focus forward or backward among focusable slots. Wraps around.
Handle Tab/Shift+Tab. Returns Key_event.Handled if consumed, Key_event.Bubble if the key should propagate.
Enable or disable a slot for Tab cycling. When disabling the currently focused slot, focus moves to the next available slot.
Nested scopes
A scope tracks a parent ring and a map of child rings. Enter a child scope with enter, exit back with exit. Tab cycles within the active scope; Esc exits the child scope.
Create a scope from a parent ring and named child rings. Each child ring is associated with a parent slot by ID.
Name of the active child ring, if in a child scope.
Enter the child ring associated with the currently focused parent slot. No-op if the focused slot has no child ring.
Exit the child ring, returning focus to the parent. No-op if already at the parent level.
Update a child ring inside a scope. No-op if the child ID is not found.
Handle keys within the scope:
- Tab/Shift+Tab cycle within the active ring
- Enter enters a child scope (if available)
- Esc exits a child scope back to the parent
- Other keys bubble.