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.internals/modal_snapshot.ml.html

Source file modal_snapshot.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
41
42
43
44
45
(******************************************************************************)
(*                                                                            *)
(* SPDX-License-Identifier: MIT                                               *)
(* Copyright (c) 2025 Nomadic Labs <contact@nomadic-labs.com>                 *)
(*                                                                            *)
(******************************************************************************)

type max_width_spec =
  | Fixed of int
  | Ratio of float
  | Clamped of {ratio : float; min : int; max : int}

let resolve_max_width spec ~cols =
  match spec with
  | Fixed n -> Some n
  | Ratio r -> Some (int_of_float (float_of_int cols *. r))
  | Clamped {ratio; min; max} ->
      let scaled = int_of_float (float_of_int cols *. ratio) in
      Some (Stdlib.max min (Stdlib.min max scaled))

let provider :
    (unit ->
    (string
    * int option
    * max_width_spec option
    * bool
    * (LTerm_geom.size -> string))
    list)
    option
    ref =
  ref None

let set_provider f = provider := Some f

let get_stack_snapshot () = match !provider with Some f -> f () | None -> []

(** Last rendered modal geometry, stored by modal_renderer for use by click handling.
    Contains (content_top_row, content_left_col) where content starts (1-indexed). *)
let last_rendered_position : (int * int) option ref = ref None

let set_rendered_position ~top ~left = last_rendered_position := Some (top, left)

let get_rendered_position () = !last_rendered_position

let clear_rendered_position () = last_rendered_position := None