projects/aports·blob master · refs

42 lines · 1.7 KiB

1Patch-Source: https://github.com/ocaml-dune/notty/pull/10
2--
3From c388d60af47ebd8106115cb7d5c10d6903be38f7 Mon Sep 17 00:00:00 2001
4From: Marek Kubica <[email protected]>
5Date: Fri, 14 Feb 2025 11:12:47 +0100
6Subject: [PATCH] Update code to use the default definition of `out_width` on
7 OCaml 5.4+
8
9Introduced in https://github.com/ocaml/ocaml/pull/13570
10
11Signed-off-by: Marek Kubica <[email protected]>
12---
13 src/notty.ml | 11 +++++++++--
14 1 file changed, 9 insertions(+), 2 deletions(-)
15
16--- a/forks/notty/src/notty.ml
17+++ b/forks/notty/src/notty.ml
18@@ -385,7 +385,12 @@ module I = struct
19
20 let create () =
21 let img, line, attr = ref empty, ref empty, ref [] in
22- let fmt = formatter_of_out_functions {
23+ (* OCaml 5.4 added a new record field so to keep compatibility, get and
24+ update the record, even if warning 23 "useless-record-with" is
25+ triggered, about all fields being updated in <5.4. *)
26+ let formatter_out_functions = get_formatter_out_functions () in
27+ let[@warning "-23"] formatter_out_functions = {
28+ formatter_out_functions with
29 out_flush = (fun () ->
30 img := !img <-> !line; line := empty; attr := [])
31 ; out_newline = (fun () ->
32@@ -395,7 +400,9 @@ module I = struct
33 (* Not entirely clear; either or both could be void: *)
34 ; out_spaces = (fun w -> line := !line <|> char (top_a attr) ' ' w 1)
35 ; out_indent = (fun w -> line := !line <|> char (top_a attr) ' ' w 1)
36- } in
37+ }
38+ in
39+ let fmt = formatter_of_out_functions formatter_out_functions in
40 pp_set_formatter_stag_functions fmt {
41 (pp_get_formatter_stag_functions fmt ()) with
42 mark_open_stag =