this repo has no description
0
fork

Configure Feed

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

Partial tooltip bindings

+146 -1
+84 -1
vendor/jsoo-code-mirror/src/tooltip/tooltip.ml
··· 1 - (* open Code_mirror *) 1 + open Code_mirror 2 2 3 3 let tooltip = Jv.get Jv.global "__CM__tooltip" 4 + 5 + module Tooltip_view = struct 6 + type t = Jv.t 7 + 8 + include (Jv.Id : Jv.CONV with type t := t) 9 + 10 + let dom t = Jv.get t "dom" |> Brr.El.of_jv 11 + 12 + type offset = { x: int; y: int } 13 + type coords = { left: int; right: int; top: int; bottom: int } 14 + 15 + let offset_to_jv { x; y } = 16 + let o = Jv.obj [||] in 17 + Jv.Int.set o "x" x; 18 + Jv.Int.set o "y" y; 19 + o 20 + 21 + let coords_to_jv { left; right; top; bottom } = 22 + let o = Jv.obj [||] in 23 + Jv.Int.set o "left" left; 24 + Jv.Int.set o "right" right; 25 + Jv.Int.set o "top" top; 26 + Jv.Int.set o "bottom" bottom; 27 + o 28 + 29 + let create ~dom ?get_coords ?overlap ?mount ?update ?positioned () = 30 + let get_coords = 31 + Option.map 32 + (fun get_coords -> 33 + Jv.repr (fun pos -> get_coords (Jv.to_int pos) |> coords_to_jv)) 34 + get_coords 35 + in 36 + let o = Jv.obj [||] in 37 + Jv.set o "dom" (Brr.El.to_jv dom); 38 + Jv.set_if_some o "getCoords" get_coords; 39 + Jv.Bool.set_if_some o "overlap" overlap; 40 + Jv.set_if_some o "mount" @@ Option.map (fun mount -> 41 + Jv.repr (fun view -> mount (Editor.View.of_jv view))) mount; 42 + Jv.set_if_some o "update" @@ Option.map (fun update -> 43 + Jv.repr (fun view_up-> update (Editor.View.Update.of_jv view_up))) update; 44 + Jv.set_if_some o "positioned" @@ Option.map Jv.repr positioned; 45 + o 46 + end 47 + 48 + module Tooltip = struct 49 + type t = Jv.t 50 + 51 + include (Jv.Id : Jv.CONV with type t := t) 52 + 53 + let pos t = Jv.Int.get t "pos" 54 + let end_ t = Jv.to_option Jv.to_int @@ Jv.get t "end" 55 + 56 + let create ~pos ?end_ ~create ?above ?strict_side ?arrow () = 57 + let o = Jv.obj [||] in 58 + Jv.Int.set o "pos" pos; 59 + Jv.Int.set_if_some o "end" end_; 60 + Jv.set o "create" @@ Jv.repr 61 + (fun view -> create (Editor.View.of_jv view) |> Tooltip_view.to_jv); 62 + Jv.Bool.set_if_some o "above" above; 63 + Jv.Bool.set_if_some o "strictSide" strict_side; 64 + Jv.Bool.set_if_some o "arrow" arrow; 65 + o 66 + end 67 + 68 + type hover_config = Jv.t 69 + let hover_config ?hide_on_change ?hover_time () = 70 + let o = Jv.obj [||] in 71 + Jv.Bool.set_if_some o "hide_on_change" hide_on_change; 72 + Jv.Int.set_if_some o "hover_time" hover_time; 73 + o 74 + 75 + let hover_tooltip ?(config = Jv.null) (source : (view:Editor.View.t -> pos:int -> side: int -> Tooltip.t option Fut.t) ) = 76 + let source = 77 + Jv.repr @@ fun view pos side -> 78 + let fut = source ~view:(Editor.View.of_jv view) ~pos:(Jv.to_int pos) 79 + ~side:(Jv.to_int side) 80 + in 81 + let fut = Fut.map (fun v -> Ok v) fut in 82 + Fut.to_promise fut ~ok:(fun t -> 83 + Option.value ~default:Jv.null (Option.map Tooltip.to_jv t)) 84 + in 85 + Jv.call tooltip "hoverTooltip" [|source|] 86 + |> Extension.of_jv
+62
vendor/jsoo-code-mirror/src/tooltip/tooltip.mli
··· 2 2 3 3 val tooltip : Jv.t 4 4 (** Global tooltip value *) 5 + 6 + module Tooltip_view : sig 7 + (** Describes the way a tooltip is displayed. *) 8 + 9 + type t 10 + (** TooltypeView *) 11 + 12 + include Jv.CONV with type t := t 13 + 14 + val dom : t -> Brr.El.t 15 + (** The DOM element to position over the editor. *) 16 + 17 + type offset = { x: int; y: int } 18 + type coords = { left: int; right: int; top: int; bottom: int } 19 + 20 + 21 + val create : 22 + dom: Brr.El.t -> 23 + ?get_coords: (int -> coords) -> 24 + ?overlap: bool -> 25 + ?mount: (Editor.View.t -> unit) -> 26 + ?update: (Editor.View.Update.t -> unit) -> 27 + ?positioned: (unit -> unit) -> 28 + unit -> t 29 + end 30 + 31 + module Tooltip : sig 32 + (** Describes a tooltip. Values of this type, when provided through the 33 + show_tooltip facet, control the individual tooltips on the editor. *) 34 + 35 + type t 36 + (** Tooltip *) 37 + 38 + include Jv.CONV with type t := t 39 + 40 + val pos : t -> int 41 + (** The document position at which to show the tooltip. *) 42 + 43 + val end_ : t -> int option 44 + (** The end of the range annotated by this tooltip, if different from pos. *) 45 + 46 + val create : 47 + pos:int -> 48 + ?end_:int -> 49 + create:(Editor.View.t -> Tooltip_view.t) -> 50 + ?above:bool -> 51 + ?strict_side:bool -> 52 + ?arrow:bool -> 53 + unit -> t 54 + end 55 + 56 + type hover_config 57 + val hover_config : 58 + ?hide_on_change: bool -> 59 + ?hover_time: int -> 60 + unit -> 61 + hover_config 62 + 63 + val hover_tooltip : 64 + ?config:hover_config -> 65 + (view:Editor.View.t -> pos:int -> side: int -> Tooltip.t option Fut.t) -> 66 + Extension.t