this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more api

+60 -3
+41 -3
src/editor.ml
··· 11 11 o 12 12 end 13 13 14 + module type Facet = sig 15 + type t 16 + include Jv.CONV with type t := t 17 + type input 18 + type output 19 + 20 + val of_ : t -> input -> Extension.t 21 + end 22 + 23 + module FacetMaker (I : sig type t val to_jv : t -> Jv.t end) : (Facet with type input = I.t and type output = Jv.t) = struct 24 + type t = Jv.t 25 + 26 + include (Jv.Id : Jv.CONV with type t := t) 27 + 28 + type input = I.t 29 + type output = Jv.t 30 + 31 + let of_ t i = 32 + Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv 33 + end 34 + 35 + type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet 36 + 14 37 type t = Jv.t 15 38 16 39 include (Jv.Id : Jv.CONV with type t := t) ··· 22 45 let doc t = Jv.get t "doc" |> Text.of_jv 23 46 end 24 47 48 + (* Helper for function *) 49 + module Func (I : sig type t include Jv.CONV with type t := t end) = struct 50 + type t = I.t -> unit 51 + let to_jv f = Jv.repr f 52 + end 53 + 25 54 module View = struct 26 55 type t = Jv.t 27 56 ··· 37 66 Jv.set_if_some o "parent" (Option.map Brr.El.to_jv parent); 38 67 o 39 68 69 + let g = Jv.get Jv.global "__CM__view" 70 + 40 71 let create ?(opts = Jv.undefined) () = 41 - Jv.new' (Jv.get Jv.global "__CM__view") [| opts |] 72 + Jv.new' g [| opts |] 42 73 43 74 let state t = Jv.get t "state" |> State.of_jv 44 75 45 76 let set_state t v = Jv.call t "setState" [| State.to_jv v |] |> ignore 46 - 47 - (* TODO *) 48 77 module Update = struct 49 78 type t = Jv.t 50 79 80 + let state t = State.of_jv @@ Jv.get t "state" 81 + 51 82 include (Jv.Id : Jv.CONV with type t := t) 52 83 end 84 + 85 + let update_listener _ : (Update.t -> unit, Jv.t) State.facet = 86 + let module F = State.FacetMaker (Func(Update)) in 87 + let jv = Jv.get g "updateListener" in 88 + Facet ((module F), F.of_jv jv) 89 + 90 + let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv 53 91 end
+19
src/editor.mli
··· 15 15 t 16 16 end 17 17 18 + module type Facet = sig 19 + type t 20 + include Jv.CONV with type t := t 21 + type input 22 + type output 23 + 24 + val of_ : t -> input -> Extension.t 25 + end 26 + 27 + module FacetMaker : functor (I : sig type t include Jv.CONV with type t := t end) -> Facet with type input = I.t 28 + 29 + type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet 30 + 18 31 val create : ?config:Config.t -> unit -> t 19 32 20 33 val doc : t -> Text.t ··· 49 62 module Update : sig 50 63 type t 51 64 65 + val state : t -> State.t 66 + 52 67 include Jv.CONV with type t := t 53 68 end 69 + 70 + val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet 71 + 72 + val line_wrapping : unit -> Extension.t 54 73 end