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.lib_miaou_internal/flash_toast_renderer.ml.html

Source file flash_toast_renderer.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
(* SPDX-License-Identifier: MIT *)
(* Render flash bus snapshots as toast notifications. *)

[@@@warning "-32-34-37-69"]

module Toast = Miaou_widgets_layout.Toast_widget
module Flash_bus = Flash_bus

let severity_of = function
  | Flash_bus.Info -> Toast.Info
  | Success -> Toast.Success
  | Warn -> Toast.Warn
  | Error -> Toast.Error

let to_toast ?position entries =
  let t = Toast.empty ?position () in
  let now = Unix.gettimeofday () in
  List.fold_left
    (fun acc (lvl, msg) -> Toast.enqueue ~now acc (severity_of lvl) msg)
    t
    entries

let render_snapshot ?position ~cols entries =
  let toast = to_toast ?position entries in
  Toast.render toast ~cols