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/src/miaou-core.driver-common/page_transition_utils.ml.html

Source file page_transition_utils.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(*****************************************************************************)
(*                                                                           *)
(* SPDX-License-Identifier: MIT                                              *)
(* Copyright (c) 2025 Nomadic Labs <contact@nomadic-labs.com>                *)
(*                                                                           *)
(*****************************************************************************)

open Miaou_core.Tui_page
module Registry = Miaou_core.Registry
module Navigation = Miaou_core.Navigation

type 'r handler = {
  on_quit : unit -> 'r;
  on_back : unit -> 'r;
  on_same_page : unit -> 'r;
  on_new_page :
    'new_s.
    (module PAGE_SIG with type state = 'new_s) -> 'new_s Navigation.t -> 'r;
}

let handle_next_page (type s r) (module P : PAGE_SIG with type state = s)
    (ps : s Navigation.t) (handler : r handler) : r =
  (* Check for pending navigation from modal callbacks *)
  let ps =
    match Miaou_core.Modal_manager.take_pending_navigation () with
    | Some (Navigation.Goto page) -> Navigation.goto page ps
    | Some Navigation.Back -> Navigation.back ps
    | Some Navigation.Quit -> Navigation.quit ps
    | None -> ps
  in
  match Navigation.pending ps with
  | Some Navigation.Quit -> handler.on_quit ()
  | Some (Navigation.Goto name) -> (
      match Registry.find name with
      | Some (module Next : PAGE_SIG) ->
          let ps_to = Next.init () in
          handler.on_new_page (module Next) ps_to
      | None -> handler.on_quit ())
  | Some Navigation.Back -> handler.on_back ()
  | None -> handler.on_same_page ()