package miaou-core
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
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_widgets_layout/canvas_widget.ml.html
Source file canvas_widget.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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73(******************************************************************************) (* *) (* SPDX-License-Identifier: MIT *) (* Copyright (c) 2025 Nomadic Labs <contact@nomadic-labs.com> *) (* Copyright (c) 2026 Mathias Bourgoin <mathias.bourgoin@atacama.tech> *) (* *) (******************************************************************************) module Canvas = Miaou_canvas.Canvas type t = { mutable canvas : Canvas.t option; mutable c_rows : int; mutable c_cols : int; } let create () = {canvas = None; c_rows = 0; c_cols = 0} let canvas t = t.canvas let canvas_exn t = match t.canvas with | Some c -> c | None -> invalid_arg "Canvas_widget.canvas_exn: canvas not allocated yet" let ensure_size t ~rows ~cols = if t.c_rows = rows && t.c_cols = cols && t.canvas <> None then () else begin t.canvas <- Some (Canvas.create ~rows ~cols) ; t.c_rows <- rows ; t.c_cols <- cols end let ensure t ~rows ~cols = ensure_size t ~rows ~cols ; t let clear t = (match t.canvas with Some c -> Canvas.clear c | None -> ()) ; t let render t ~size = let rows = size.LTerm_geom.rows in let cols = size.LTerm_geom.cols in ensure_size t ~rows ~cols ; match t.canvas with | Some c -> (* Use theme's default colors for cells without explicit fg/bg *) let theme = Miaou_style.Style_context.current_theme () in let text_style = theme.Miaou_style.Theme.text in let bg_style = theme.Miaou_style.Theme.background in let resolved_text = Miaou_style.Style.to_resolved ~dark_mode:theme.Miaou_style.Theme.dark_mode text_style in let resolved_bg = Miaou_style.Style.to_resolved ~dark_mode:theme.Miaou_style.Theme.dark_mode bg_style in Canvas.to_ansi_with_defaults ~default_fg:resolved_text.Miaou_style.Style.r_fg ~default_bg:resolved_bg.Miaou_style.Style.r_bg c | None -> "" let rows t = t.c_rows let cols t = t.c_cols let () = Miaou_registry.register ~name:"canvas" ~mli:[%blob "canvas_widget.mli"] ()
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>