this repo has no description
0
fork

Configure Feed

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

fmt

+111 -83
+1
.ocamlformat
··· 1 + version=0.18.0
+1 -1
example/src/dune
··· 7 7 8 8 (alias 9 9 (name default) 10 - (deps index.html)) 10 + (deps index.html))
+11 -8
example/src/index.ml
··· 1 1 open Code_mirror 2 2 open Brr 3 + 3 4 let basic_setup = Jv.get Jv.global "__CM__basic_setup" |> Extension.of_jv 4 - let markdown () = 5 - let md = Jv.get Jv.global "__CM__markdown" in 6 - Jv.apply md [||] |> Extension.of_jv 7 5 6 + let markdown () = 7 + let md = Jv.get Jv.global "__CM__markdown" in 8 + Jv.apply md [||] |> Extension.of_jv 8 9 9 10 let () = 10 - let open Editor in 11 - let config = State.Config.create ~extensions:[| basic_setup; markdown () |] () in 12 - let state = State.create ~config () in 11 + let open Editor in 12 + let config = 13 + State.Config.create ~extensions:[| basic_setup; markdown () |] () 14 + in 15 + let state = State.create ~config () in 13 16 let opts = View.opts ~state ~parent:(Document.body G.document) () in 14 - let _editor : View.t = View.create ~opts () in 17 + let _editor : View.t = View.create ~opts () in 15 18 Console.log [ _editor; state; config ]; 16 - () 19 + ()
+1 -1
src/code_mirror.ml
··· 1 1 module Editor = Editor 2 2 module Text = Text 3 - module Extension = Extension 3 + module Extension = Extension
+1 -1
src/dune
··· 3 3 (public_name code-mirror) 4 4 (js_of_ocaml 5 5 (javascript_files codemirror.js)) 6 - (libraries brr js_of_ocaml)) 6 + (libraries brr js_of_ocaml))
+17 -16
src/editor.ml
··· 1 - module State = struct 2 - 3 - module Config = struct 1 + module State = struct 2 + module Config = struct 4 3 type t = Jv.t 5 4 6 - let create ?doc ?selection ?extensions () = 5 + let create ?doc ?selection ?extensions () = 7 6 let o = Jv.obj [||] in 8 7 Jv.Jstr.set_if_some o "doc" doc; 9 8 Jv.set_if_some o "selection" selection; 10 - Jv.set_if_some o "extensions" (Option.map (Jv.of_array Extension.to_jv) extensions); 9 + Jv.set_if_some o "extensions" 10 + (Option.map (Jv.of_array Extension.to_jv) extensions); 11 11 o 12 12 end 13 13 ··· 15 15 16 16 include (Jv.Id : Jv.CONV with type t := t) 17 17 18 - let create ?(config = Jv.undefined) () = 19 - let editor_state = Jv.get Jv.global "__CM__state" in 18 + let create ?(config = Jv.undefined) () = 19 + let editor_state = Jv.get Jv.global "__CM__state" in 20 20 Jv.call editor_state "create" [| config |] 21 - end 21 + end 22 22 23 - module View = struct 23 + module View = struct 24 24 type t = Jv.t 25 25 26 26 include (Jv.Id : Jv.CONV with type t := t) 27 27 28 - type opts = Jv.t 28 + type opts = Jv.t 29 29 30 - let opts ?state ?root ?dispatch ?parent () = 30 + let opts ?state ?root ?dispatch ?parent () = 31 31 let o = Jv.obj [||] in 32 32 Jv.set_if_some o "state" state; 33 33 Jv.set_if_some o "root" (Option.map Brr.Document.to_jv root); ··· 35 35 Jv.set_if_some o "parent" (Option.map Brr.El.to_jv parent); 36 36 o 37 37 38 - let create ?(opts = Jv.undefined) () = 38 + let create ?(opts = Jv.undefined) () = 39 39 Jv.new' (Jv.get Jv.global "__CM__view") [| opts |] 40 40 41 - (* TODO *) 42 - module Update = struct 43 - type t = Jv.t 41 + (* TODO *) 42 + module Update = struct 43 + type t = Jv.t 44 + 44 45 include (Jv.Id : Jv.CONV with type t := t) 45 46 end 46 - end 47 + end
+37 -25
src/editor.mli
··· 1 - module State : sig 1 + module State : sig 2 + type t 3 + 4 + include Jv.CONV with type t := t 5 + 6 + module Config : sig 2 7 type t 3 8 4 - include Jv.CONV with type t := t 9 + (* TODO: Add selection *) 10 + val create : 11 + ?doc:Jstr.t -> 12 + ?selection:Jv.t -> 13 + ?extensions:Extension.t array -> 14 + unit -> 15 + t 16 + end 5 17 6 - module Config : sig 7 - type t 8 - 9 - (* TODO: Add selection *) 10 - val create : ?doc:Jstr.t -> ?selection:Jv.t -> ?extensions:Extension.t array -> unit -> t 11 - end 12 - 13 - val create : ?config:Config.t -> unit -> t 18 + val create : ?config:Config.t -> unit -> t 14 19 end 15 20 16 - module View : sig 17 - type t 18 - (** Editor view *) 21 + module View : sig 22 + type t 23 + (** Editor view *) 19 24 20 - include Jv.CONV with type t := t 25 + include Jv.CONV with type t := t 21 26 22 - type opts 23 - (** Configurable options for the editor view *) 27 + type opts 28 + (** Configurable options for the editor view *) 24 29 25 - (* TODO: Dispatch function *) 26 - val opts : ?state:State.t -> ?root:Brr.El.document -> ?dispatch:Jv.t -> ?parent:Brr.El.t -> unit -> opts 30 + (* TODO: Dispatch function *) 31 + val opts : 32 + ?state:State.t -> 33 + ?root:Brr.El.document -> 34 + ?dispatch:Jv.t -> 35 + ?parent:Brr.El.t -> 36 + unit -> 37 + opts 38 + 39 + val create : ?opts:opts -> unit -> t 40 + (** Create a new view *) 27 41 28 - val create : ?opts:opts -> unit -> t 29 - (** Create a new view *) 42 + module Update : sig 43 + type t 30 44 31 - module Update : sig 32 - type t 33 - include Jv.CONV with type t := t 34 - end 35 - end 45 + include Jv.CONV with type t := t 46 + end 47 + end
+1 -1
src/extension.ml
··· 1 1 type t = Jv.t 2 2 3 - include (Jv.Id : Jv.CONV with type t := t) 3 + include (Jv.Id : Jv.CONV with type t := t)
+1 -1
src/extension.mli
··· 1 1 type t 2 2 (** Extensions for the editor *) 3 3 4 - include Jv.CONV with type t := t 4 + include Jv.CONV with type t := t
+15 -8
src/panel.ml
··· 1 1 open Brr 2 - type t = Jv.t 2 + 3 + type t = Jv.t 3 4 4 5 include (Jv.Id : Jv.CONV with type t := t) 5 6 6 7 let create ?mount ?update ?top ?pos dom = 7 - let o = Jv.obj [||] in 8 - Jv.set_if_some o "mount" (Option.map Jv.repr mount); 9 - 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); 10 - Jv.Bool.set_if_some o "top" top; 11 - Jv.Int.set_if_some o "pos" pos; 12 - Jv.set o "dom" (El.to_jv dom); 13 - o 8 + let o = Jv.obj [||] in 9 + Jv.set_if_some o "mount" (Option.map Jv.repr mount); 10 + Jv.set_if_some o "update" 11 + (Option.map 12 + (fun u -> 13 + let u' jv = u (Editor.View.Update.of_jv jv) in 14 + u') 15 + update 16 + |> Option.map Jv.repr); 17 + Jv.Bool.set_if_some o "top" top; 18 + Jv.Int.set_if_some o "pos" pos; 19 + Jv.set o "dom" (El.to_jv dom); 20 + o
+7 -2
src/panel.mli
··· 3 3 4 4 include Jv.CONV with type t := t 5 5 6 - 7 - val create : ?mount:(unit -> unit) -> ?update:(Editor.View.Update.t -> unit) -> ?top:bool -> ?pos:int -> Brr.El.t -> t 6 + val create : 7 + ?mount:(unit -> unit) -> 8 + ?update:(Editor.View.Update.t -> unit) -> 9 + ?top:bool -> 10 + ?pos:int -> 11 + Brr.El.t -> 12 + t
+1 -1
src/text.ml
··· 2 2 type t = Jv.t 3 3 4 4 let from t = Jv.Int.get t "from" 5 + 5 6 let to_ t = Jv.Int.get t "to" 6 7 7 8 let number t = Jv.Int.get t "number" ··· 10 11 11 12 let length t = Jv.Int.get t "length" 12 13 end 13 -
+17 -18
src/text.mli
··· 1 1 module Line : sig 2 - type t 3 - (** A text line *) 4 - 5 - val from : t -> int 6 - (** Position of the start of the line *) 7 - 8 - val to_ : t -> int 9 - (** Position at the end of the line before the line break *) 2 + type t 3 + (** A text line *) 4 + 5 + val from : t -> int 6 + (** Position of the start of the line *) 7 + 8 + val to_ : t -> int 9 + (** Position at the end of the line before the line break *) 10 + 11 + val number : t -> int 12 + (** Line's number (1-based) *) 13 + 14 + val text : t -> Jstr.t 15 + (** Line's text *) 10 16 11 - val number : t -> int 12 - (** Line's number (1-based) *) 13 - 14 - val text : t -> Jstr.t 15 - (** Line's text *) 16 - 17 - val length : t -> int 18 - (** The length of the line *) 19 - end 20 - 17 + val length : t -> int 18 + (** The length of the line *) 19 + end