···1+module Widget = struct
2+ type t = Jv.t
3+4+ include (Jv.Id : Jv.CONV with type t := t)
5+6+ let widget_type = Jv.get Jv.global "__CM__widgetType"
7+8+ let make to_dom =
9+ let w = Jv.new' widget_type [||] in
10+ Jv.set w "toDOM" (Jv.callback ~arity:1 (fun _view -> to_dom ()));
11+ w
12+end
13+14+type t = Jv.t
15+16+include (Jv.Id : Jv.CONV with type t := t)
17+18+let decoration = Jv.get Jv.global "__CM__decoration"
19+20+let widget ?block ?side w =
21+ let block =
22+ match block with None -> [] | Some b -> [ ("block", Jv.of_bool b) ]
23+ in
24+ let side =
25+ match side with None -> [] | Some s -> [ ("side", Jv.of_int s) ]
26+ in
27+ let spec =
28+ Jv.obj (Array.of_list (("widget", Widget.to_jv w) :: (block @ side)))
29+ in
30+ Jv.call decoration "widget" [| spec |] |> of_jv
31+32+module Range = struct
33+ type t = Jv.t
34+35+ include (Jv.Id : Jv.CONV with type t := t)
36+end
37+38+let range ~from ~to_ t =
39+ Jv.call t "range" [| Jv.of_int from; Jv.of_int to_ |] |> Range.of_jv
40+41+module Range_set = struct
42+ type t = Jv.t
43+44+ include (Jv.Id : Jv.CONV with type t := t)
45+46+ let range_set = Jv.get Jv.global "__CM__rangeSet"
47+48+ let of' ranges =
49+ Jv.call range_set "of" [| Jv.of_array Range.to_jv ranges |] |> of_jv
50+end
+29
src/decoration.mli
···00000000000000000000000000000
···1+module Widget : sig
2+ type t
3+4+ include Jv.CONV with type t := t
5+6+ val make : (unit -> Brr.El.t) -> t
7+end
8+9+type t
10+11+include Jv.CONV with type t := t
12+13+val widget : ?block:bool -> ?side:int -> Widget.t -> t
14+15+module Range : sig
16+ type t
17+18+ include Jv.CONV with type t := t
19+end
20+21+val range : from:int -> to_:int -> t -> Range.t
22+23+module Range_set : sig
24+ type t
25+26+ include Jv.CONV with type t := t
27+28+ val of' : Range.t array -> t
29+end
+10-1
src/editor.ml
···108109 let dom t = Jv.get t "dom" |> Brr.El.of_jv
110111- let update_listener _ : (Update.t -> unit, Jv.t) State.facet =
112 let module F = State.FacetMaker (Func (Update)) in
113 let jv = Jv.get g "updateListener" in
114 Facet ((module F), F.of_jv jv)
000000000115116 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
117
···108109 let dom t = Jv.get t "dom" |> Brr.El.of_jv
110111+ let update_listener () : (Update.t -> unit, Jv.t) State.facet =
112 let module F = State.FacetMaker (Func (Update)) in
113 let jv = Jv.get g "updateListener" in
114 Facet ((module F), F.of_jv jv)
115+116+ let decorations () : (Decoration.Range_set.t, Jv.t) State.facet =
117+ let module F = State.FacetMaker (Decoration.Range_set) in
118+ let jv = Jv.get g "decorations" in
119+ Facet ((module F), F.of_jv jv)
120+121+ let request_measure t =
122+ let _ = Jv.call t "requestMeasure" [||] in
123+ ()
124125 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
126
+2
src/editor.mli
···8182 val dom : t -> Brr.El.t
83 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
0084 val line_wrapping : unit -> Extension.t
85 val set_doc : t -> Jstr.t -> unit
86end
···8182 val dom : t -> Brr.El.t
83 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
84+ val decorations : unit -> (Decoration.Range_set.t, Jv.t) State.facet
85+ val request_measure : t -> unit
86 val line_wrapping : unit -> Extension.t
87 val set_doc : t -> Jstr.t -> unit
88end