···11-module State = struct
22-33- module Config = struct
11+module State = struct
22+ module Config = struct
43 type t = Jv.t
5466- let create ?doc ?selection ?extensions () =
55+ let create ?doc ?selection ?extensions () =
76 let o = Jv.obj [||] in
87 Jv.Jstr.set_if_some o "doc" doc;
98 Jv.set_if_some o "selection" selection;
1010- Jv.set_if_some o "extensions" (Option.map (Jv.of_array Extension.to_jv) extensions);
99+ Jv.set_if_some o "extensions"
1010+ (Option.map (Jv.of_array Extension.to_jv) extensions);
1111 o
1212 end
1313···15151616 include (Jv.Id : Jv.CONV with type t := t)
17171818- let create ?(config = Jv.undefined) () =
1919- let editor_state = Jv.get Jv.global "__CM__state" in
1818+ let create ?(config = Jv.undefined) () =
1919+ let editor_state = Jv.get Jv.global "__CM__state" in
2020 Jv.call editor_state "create" [| config |]
2121-end
2121+end
22222323-module View = struct
2323+module View = struct
2424 type t = Jv.t
25252626 include (Jv.Id : Jv.CONV with type t := t)
27272828- type opts = Jv.t
2828+ type opts = Jv.t
29293030- let opts ?state ?root ?dispatch ?parent () =
3030+ let opts ?state ?root ?dispatch ?parent () =
3131 let o = Jv.obj [||] in
3232 Jv.set_if_some o "state" state;
3333 Jv.set_if_some o "root" (Option.map Brr.Document.to_jv root);
···3535 Jv.set_if_some o "parent" (Option.map Brr.El.to_jv parent);
3636 o
37373838- let create ?(opts = Jv.undefined) () =
3838+ let create ?(opts = Jv.undefined) () =
3939 Jv.new' (Jv.get Jv.global "__CM__view") [| opts |]
40404141- (* TODO *)
4242- module Update = struct
4343- type t = Jv.t
4141+ (* TODO *)
4242+ module Update = struct
4343+ type t = Jv.t
4444+4445 include (Jv.Id : Jv.CONV with type t := t)
4546 end
4646-end4747+end
+37-25
src/editor.mli
···11-module State : sig
11+module State : sig
22+ type t
33+44+ include Jv.CONV with type t := t
55+66+ module Config : sig
27 type t
3844- include Jv.CONV with type t := t
99+ (* TODO: Add selection *)
1010+ val create :
1111+ ?doc:Jstr.t ->
1212+ ?selection:Jv.t ->
1313+ ?extensions:Extension.t array ->
1414+ unit ->
1515+ t
1616+ end
51766- module Config : sig
77- type t
88-99- (* TODO: Add selection *)
1010- val create : ?doc:Jstr.t -> ?selection:Jv.t -> ?extensions:Extension.t array -> unit -> t
1111- end
1212-1313- val create : ?config:Config.t -> unit -> t
1818+ val create : ?config:Config.t -> unit -> t
1419end
15201616-module View : sig
1717- type t
1818- (** Editor view *)
2121+module View : sig
2222+ type t
2323+ (** Editor view *)
19242020- include Jv.CONV with type t := t
2525+ include Jv.CONV with type t := t
21262222- type opts
2323- (** Configurable options for the editor view *)
2727+ type opts
2828+ (** Configurable options for the editor view *)
24292525- (* TODO: Dispatch function *)
2626- val opts : ?state:State.t -> ?root:Brr.El.document -> ?dispatch:Jv.t -> ?parent:Brr.El.t -> unit -> opts
3030+ (* TODO: Dispatch function *)
3131+ val opts :
3232+ ?state:State.t ->
3333+ ?root:Brr.El.document ->
3434+ ?dispatch:Jv.t ->
3535+ ?parent:Brr.El.t ->
3636+ unit ->
3737+ opts
3838+3939+ val create : ?opts:opts -> unit -> t
4040+ (** Create a new view *)
27412828- val create : ?opts:opts -> unit -> t
2929- (** Create a new view *)
4242+ module Update : sig
4343+ type t
30443131- module Update : sig
3232- type t
3333- include Jv.CONV with type t := t
3434- end
3535-end 4545+ include Jv.CONV with type t := t
4646+ end
4747+end
+1-1
src/extension.ml
···11type t = Jv.t
2233-include (Jv.Id : Jv.CONV with type t := t)33+include (Jv.Id : Jv.CONV with type t := t)
+1-1
src/extension.mli
···11type t
22(** Extensions for the editor *)
3344-include Jv.CONV with type t := t44+include Jv.CONV with type t := t
+15-8
src/panel.ml
···11open Brr
22-type t = Jv.t
22+33+type t = Jv.t
3445include (Jv.Id : Jv.CONV with type t := t)
5667let create ?mount ?update ?top ?pos dom =
77- let o = Jv.obj [||] in
88- Jv.set_if_some o "mount" (Option.map Jv.repr mount);
99- Jv.set_if_some o "update" (Option.map (fun u -> let u' jv = u (Editor.View.Update.of_jv jv) in u') update |> Option.map Jv.repr);
1010- Jv.Bool.set_if_some o "top" top;
1111- Jv.Int.set_if_some o "pos" pos;
1212- Jv.set o "dom" (El.to_jv dom);
1313- o88+ let o = Jv.obj [||] in
99+ Jv.set_if_some o "mount" (Option.map Jv.repr mount);
1010+ Jv.set_if_some o "update"
1111+ (Option.map
1212+ (fun u ->
1313+ let u' jv = u (Editor.View.Update.of_jv jv) in
1414+ u')
1515+ update
1616+ |> Option.map Jv.repr);
1717+ Jv.Bool.set_if_some o "top" top;
1818+ Jv.Int.set_if_some o "pos" pos;
1919+ Jv.set o "dom" (El.to_jv dom);
2020+ o
+7-2
src/panel.mli
···3344include Jv.CONV with type t := t
5566-77-val create : ?mount:(unit -> unit) -> ?update:(Editor.View.Update.t -> unit) -> ?top:bool -> ?pos:int -> Brr.El.t -> t66+val create :
77+ ?mount:(unit -> unit) ->
88+ ?update:(Editor.View.Update.t -> unit) ->
99+ ?top:bool ->
1010+ ?pos:int ->
1111+ Brr.El.t ->
1212+ t
+1-1
src/text.ml
···22 type t = Jv.t
3344 let from t = Jv.Int.get t "from"
55+56 let to_ t = Jv.Int.get t "to"
6778 let number t = Jv.Int.get t "number"
···10111112 let length t = Jv.Int.get t "length"
1213end
1313-
+17-18
src/text.mli
···11module Line : sig
22- type t
33- (** A text line *)
44-55- val from : t -> int
66- (** Position of the start of the line *)
77-88- val to_ : t -> int
99- (** Position at the end of the line before the line break *)
22+ type t
33+ (** A text line *)
44+55+ val from : t -> int
66+ (** Position of the start of the line *)
77+88+ val to_ : t -> int
99+ (** Position at the end of the line before the line break *)
1010+1111+ val number : t -> int
1212+ (** Line's number (1-based) *)
1313+1414+ val text : t -> Jstr.t
1515+ (** Line's text *)
10161111- val number : t -> int
1212- (** Line's number (1-based) *)
1313-1414- val text : t -> Jstr.t
1515- (** Line's text *)
1616-1717- val length : t -> int
1818- (** The length of the line *)
1919- end
2020-1717+ val length : t -> int
1818+ (** The length of the line *)
1919+end