···2323 let data : Protocol.answer = Marshal.from_bytes data_marshaled 0 in
2424 res_fut worker data
2525 in
2626- Ev.listen Brr_io.Message.Ev.message on_message @@
2727- Worker.as_target worker.worker;
2626+ let _listener =
2727+ Ev.listen Brr_io.Message.Ev.message on_message @@
2828+ Worker.as_target worker.worker
2929+ in
2830 worker
29313032(* todo share that with worker *)
···11-# This is a basic workflow to help you get started with Actions
22-33-name: CI
44-55-# Controls when the action will run. Triggers the workflow on push or pull request
66-# events but only for the master branch
77-on:
88- push:
99- branches:
1010- - "*"
1111- pull_request:
1212- branches:
1313- - "*"
1414-1515-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1616-jobs:
1717- # This workflow contains a single job called "build"
1818- build:
1919- strategy:
2020- fail-fast: false
2121- matrix:
2222- os:
2323- - ubuntu-latest
2424- ocaml-compiler:
2525- - 4.14.x
2626- # The type of runner that the job will run on
2727- runs-on: ${{ matrix.os }}
2828-2929- # Steps represent a sequence of tasks that will be executed as part of the job
3030- steps:
3131- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3232- - uses: actions/checkout@v3
3333-3434- - name: Set up OCaml ${{ matrix.ocaml-compiler }}
3535- uses: ocaml/setup-ocaml@v2
3636- with:
3737- # Version of the OCaml compiler to initialise
3838- ocaml-compiler: ${{ matrix.ocaml-compiler }}
3939-4040- - name: Install dependencies
4141- run: |
4242- opam install . --deps-only --with-test
4343-4444- - name: Build and test in release mode
4545- run: opam install . --with-test
···11-; DO NOT EDIT (unless you know what you are doing)
22-;
33-; This subdirectory is a git "subrepo", and this file is maintained by the
44-; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
55-;
66-[subrepo]
77- remote = git@github.com:voodoos/jsoo-code-mirror.git
88- branch = main
99- commit = 8fe48910e265ff87f9fc94ceb7b3d19fac102a96
1010- parent = b6c3b3124430bf8db186c5f73e8b1df6e4c80565
1111- method = merge
1212- cmdver = 0.4.5
···11-.PHONY: example node bundle fmt
22-example:
33- dune build --ignore-promoted-rules
44- parcel _build/default/example/src/index.html
55-66-node:
77- npm install
88-99-# Use that command if you want to re-generate the static bundled in the includes
1010-# folder, for example if there was an update of code-mirror.
1111-bundle: node
1212- dune build --profile=with-bundle
1313-1414-fmt:
1515- dune build @fmt --auto-promote
-6
vendor/jsoo-code-mirror/README.md
···11-jsoo-code-mirror
22-----------------
33-44-*Very, very incomplete*
55-66-Some bindings using [brr](https://erratique.ch/software/brr) to [code-mirror 6](https://codemirror.net/6/).
···11-(rule
22- (deps
33- (source_tree %{project_root}/node_modules))
44- (target bundle-es6.js)
55- (enabled_if
66- (= %{profile} "with-bundle"))
77- (action
88- (run
99- %{project_root}/node_modules/esbuild/bin/esbuild
1010- %{dep:includes.js}
1111- --bundle
1212- --outfile=%{target})))
1313-1414-; warning: node modules are not managed by dune
1515-; to generate a new bundle one should run `npm install` before the first build
1616-1717-(rule
1818- (deps
1919- %{project_root}/package.json
2020- %{project_root}/babel.config.js
2121- (source_tree %{project_root}/node_modules))
2222- (target bundle.js)
2323- (mode promote)
2424- (enabled_if
2525- (= %{profile} "with-bundle"))
2626- (action
2727- (run
2828- %{project_root}/node_modules/@babel/cli/bin/babel.js
2929- %{dep:bundle-es6.js}
3030- --config-file
3131- %{project_root}/babel.config.js
3232- -o
3333- %{target})))
3434-3535-; The bundle is only re-generated if the profile is `with-bundle`
3636-; If you add new javascript dependency or update the package.json
3737-; you should run `dune build --profile=with-bundle`
-18
vendor/jsoo-code-mirror/includes/includes.js
···11-import { EditorView, basicSetup } from "codemirror"
22-import { EditorState } from "@codemirror/state"
33-import { hoverTooltip } from "@codemirror/view"
44-import * as lint from "@codemirror/lint"
55-import * as autocomplete from "@codemirror/autocomplete"
66-import * as dark from "@codemirror/theme-one-dark"
77-import * as language from "@codemirror/language"
88-import { oCaml } from "@codemirror/legacy-modes/mode/mllike"
99-1010-joo_global_object.__CM__view = EditorView;
1111-joo_global_object.__CM__state = EditorState;
1212-joo_global_object.__CM__lint = lint;
1313-joo_global_object.__CM__autocomplete = autocomplete;
1414-joo_global_object.__CM__hoverTooltip = hoverTooltip;
1515-joo_global_object.__CM__basic_setup = basicSetup
1616-joo_global_object.__CM__dark = dark;
1717-joo_global_object.__CM__stream_parser = language;
1818-joo_global_object.__CM__mllike = oCaml;
···11-open Code_mirror
22-module RegExp = RegExp
33-44-let autocomplete = Jv.get Jv.global "__CM__autocomplete"
55-66-module Completion = struct
77- type t = Jv.t
88-99- include (Jv.Id : Jv.CONV with type t := t)
1010-1111- let set_if_some_string t s v = Jv.Jstr.set_if_some t s (Option.map Jstr.v v)
1212- let set_string t s v = Jv.Jstr.set t s (Jstr.v v)
1313-1414- let create ~label ?detail ?info ?apply ?type_ ?boost () =
1515- let o = Jv.obj [||] in
1616- set_string o "label" label;
1717- set_if_some_string o "detail" detail;
1818- set_if_some_string o "info" info;
1919- Jv.set_if_some o "apply" apply;
2020- set_if_some_string o "type" type_;
2121- Jv.Int.set_if_some o "boost" boost;
2222- o
2323-end
2424-2525-module Context = struct
2626- type t = Jv.t
2727- (** Completion context *)
2828-2929- include (Jv.Id : Jv.CONV with type t := t)
3030-3131- let state t = Jv.get t "state" |> Editor.State.of_jv
3232- let pos t = Jv.Int.get t "pos"
3333- let explicit t = Jv.Bool.get t "explicit"
3434-3535- let token_before t types =
3636- let jv = Jv.call t "tokenBefore" [| Jv.of_list Jv.of_string types |] in
3737- if Jv.is_none jv then None else Some jv
3838-3939- let match_before t regex =
4040- let jv = Jv.call t "matchBefore" [| RegExp.to_jv regex |] in
4141- if Jv.is_none jv then None else Some jv
4242-4343- let aborted t = Jv.Bool.get t "aborted"
4444-end
4545-4646-module Result = struct
4747- type t = Jv.t
4848- (** Completion result *)
4949-5050- include (Jv.Id : Jv.CONV with type t := t)
5151-5252- let create ~from ?to_ ~options ?span ?filter () =
5353- let o = Jv.obj [||] in
5454- Jv.Int.set o "from" from;
5555- Jv.Int.set_if_some o "to" to_;
5656- Jv.set o "options" (Jv.of_list Completion.to_jv options);
5757- Jv.set_if_some o "span" (Option.map RegExp.to_jv span);
5858- Jv.Bool.set_if_some o "filter" filter;
5959- o
6060-end
6161-6262-module Source = struct
6363- type t = Jv.t
6464-6565- include (Jv.Id : Jv.CONV with type t := t)
6666-6767- let create (src : Context.t -> Result.t option Fut.t) =
6868- let f ctx =
6969- let fut = Fut.map (fun v -> Ok v) @@ src (Context.of_jv ctx) in
7070- Fut.to_promise fut ~ok:(fun t ->
7171- Option.value ~default:Jv.null (Option.map Result.to_jv t))
7272- in
7373- Jv.repr f
7474-7575- let from_list (l : Completion.t list) =
7676- Jv.call autocomplete "completeFromList" [| Jv.of_jv_list l |] |> of_jv
7777-end
7878-7979-type config = Jv.t
8080-8181-let config ?activate_on_typing ?override ?max_rendered_options ?default_key_map
8282- ?above_cursor ?option_class ?icons ?add_to_options () =
8383- let o = Jv.obj [||] in
8484- Jv.Bool.set_if_some o "activateOnTyping" activate_on_typing;
8585- Jv.set_if_some o "override" (Option.map (fun v -> Jv.of_jv_list v) override);
8686- Jv.Int.set_if_some o "maxRenderedOptions" max_rendered_options;
8787- Jv.Bool.set_if_some o "defaultKeyMap" default_key_map;
8888- Jv.Bool.set_if_some o "aboveCursor" above_cursor;
8989- Jv.set_if_some o "optionClass" option_class;
9090- Jv.Bool.set_if_some o "icons" icons;
9191- Jv.set_if_some o "addToOptions" add_to_options;
9292- o
9393-9494-let create ?(config = Jv.null) () =
9595- Extension.of_jv @@ Jv.call autocomplete "autocompletion" [| config |]
9696-9797-(* type status = Active | Pending
9898-9999- let status state =
100100-101101- val status : Editor.State.t -> status option
102102- (** Gets the current completion status *)
103103-104104- val current_completions : Editor.State.t -> Completion.t list
105105- (** Returns the current available completions *)
106106-107107- val selected_completion : Editor.State.t -> Completion.t option
108108- * Returh the currently selected completion if any *)
···11-open Code_mirror
22-33-(** Most of this documention originate from the code-mirror reference.
44-55- {{:https://codemirror.net/6/docs/ref/#autocomplete} Visit the
66- reference directly for additional information.} *)
77-88-val autocomplete : Jv.t
99-(** Global autocomplete value *)
1010-1111-module RegExp = RegExp
1212-1313-module Completion : sig
1414- (** Represents individual completions. *)
1515-1616- type t
1717- (** Completion *)
1818-1919- include Jv.CONV with type t := t
2020-2121- val create :
2222- label:string ->
2323- ?detail:string ->
2424- ?info:string ->
2525- ?apply:t ->
2626- ?type_:string ->
2727- ?boost:int ->
2828- unit ->
2929- t
3030- (** Creates a completion.
3131-3232- @param label The label to show in the completion picker.
3333- @param detail An optional short piece of information to show after the
3434- label.
3535- @param info Additional info to show when the completion is selected.
3636- @param apply (todo) How to apply the completion.
3737- @param type The type of the completion. This is used to pick an icon to
3838- show for the completion.
3939- @param boost
4040-4141- {{:https://codemirror.net/6/docs/ref/#autocomplete.Completion} See the
4242- reference for additional information.} *)
4343-end
4444-4545-module Context : sig
4646- (** An instance of this is passed to completion source functions. *)
4747-4848- type t
4949- (** Completion context *)
5050-5151- include Jv.CONV with type t := t
5252-5353- val state : t -> Editor.State.t
5454- (** The editor state that the completion happens in. *)
5555-5656- val pos : t -> int
5757- (** The position at which the completion is happening. *)
5858-5959- val explicit : t -> bool
6060- (** Indicates whether completion was activated explicitly, or implicitly by
6161- typing. The usual way to respond to this is to only return completions when
6262- either there is part of a completable entity before the cursor, or explicit
6363- is true. *)
6464-6565- val token_before : t -> string list -> Jv.t option
6666- (** Get the extent, content, and (if there is a token) type of the token
6767- before this.pos. *)
6868-6969- val match_before : t -> RegExp.t -> Jv.t option
7070- (** Get the match of the given expression directly before the cursor. *)
7171-7272- val aborted : t -> bool
7373- (** Yields true when the query has been aborted. Can be useful in
7474- asynchronous queries to avoid doing work that will be ignored. *)
7575-end
7676-7777-module Result : sig
7878- (** Objects returned by completion sources. *)
7979-8080- type t
8181- (** Completion result *)
8282-8383- include Jv.CONV with type t := t
8484-8585- val create :
8686- from:int ->
8787- ?to_:int ->
8888- options:Completion.t list ->
8989- ?span:RegExp.t ->
9090- ?filter:bool ->
9191- unit ->
9292- t
9393- (** Creating a new completion result (see {{: https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult} the docs}).
9494- @param from The start of the range that is being completed.
9595- @param to_ The end of the range that is being completed. Defaults to the
9696- main cursor position.
9797- @param options The completions returned.
9898- @param span When given, further input that causes the part of the document
9999- between [from] and [to_] to match this regular expression will not query
100100- the completion source again
101101- @param filter By default, the library filters and scores completions. Set
102102- filter to false to disable this, and cause your completions to all be
103103- included, in the order they were given.
104104- *)
105105-end
106106-107107-module Source : sig
108108- type t
109109- (** Completion source *)
110110-111111- include Jv.CONV with type t := t
112112-113113- val create : (Context.t -> Result.t option Fut.t) -> t
114114-115115- val from_list : Completion.t list -> t
116116- (** Given a a fixed array of options, return an autocompleter that completes
117117- them. *)
118118-end
119119-120120-type config
121121-122122-val config :
123123- ?activate_on_typing:bool ->
124124- ?override:Source.t list ->
125125- ?max_rendered_options:int ->
126126- ?default_key_map:bool ->
127127- ?above_cursor:bool ->
128128- ?option_class:Jv.t ->
129129- ?icons:bool ->
130130- ?add_to_options:Jv.t ->
131131- unit ->
132132- config
133133-(** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*)
134134-135135-val create : ?config:config -> unit -> Code_mirror.Extension.t
136136-(** Autocompleter *)
···11-type t
22-(** A regular expression *)
33-44-include Jv.CONV with type t := t
55-66-type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky
77-88-val create : ?opts:opts list -> string -> t
99-(** Create a regular expression from a string. Internally this uses
1010- [new RegExp(s)] which
1111- {{:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp}
1212- has it's own documentation}. Note we pass noo flags at the moment. *)
1313-1414-type result
1515-(** The result of executing a regular expression search on a string *)
1616-1717-val get_full_string_match : result -> string
1818-(** The matched text *)
1919-2020-val get_index : result -> int
2121-(** 0-based index of the match in the string *)
2222-2323-val get_indices : result -> (int * int) list
2424-(** Each entry is a substring match of [(start, end_)] *)
2525-2626-val get_substring_matches : result -> string list
2727-(** The matches for the parennthetical capture groups *)
2828-2929-val exec : t -> string -> result option
3030-(** [exec t s] using the regular expression [t] to execute a search for a match
3131- in a specified string [s]. *)
3232-3333-val exec' : t -> Jstr.t -> result option
3434-(** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
-3
vendor/jsoo-code-mirror/src/code_mirror.ml
···11-module Editor = Editor
22-module Text = Text
33-module Extension = Extension
···11-module State = struct
22- module Config = struct
33- type t = Jv.t
44-55- let create ?doc ?selection ?extensions () =
66- let o = Jv.obj [||] in
77- Jv.Jstr.set_if_some o "doc" doc;
88- Jv.set_if_some o "selection" selection;
99- Jv.set_if_some o "extensions"
1010- (Option.map (Jv.of_array Extension.to_jv) extensions);
1111- o
1212- end
1313-1414- module type Facet = sig
1515- type t
1616-1717- include Jv.CONV with type t := t
1818-1919- type input
2020- type output
2121-2222- val of_ : t -> input -> Extension.t
2323- end
2424-2525- module FacetMaker (I : sig
2626- type t
2727-2828- val to_jv : t -> Jv.t
2929- end) : Facet with type input = I.t and type output = Jv.t = struct
3030- type t = Jv.t
3131-3232- include (Jv.Id : Jv.CONV with type t := t)
3333-3434- type input = I.t
3535- type output = Jv.t
3636-3737- let of_ t i = Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv
3838- end
3939-4040- type ('i, 'o) facet =
4141- | Facet :
4242- (module Facet with type input = 'i and type output = 'o and type t = 'a)
4343- * 'a
4444- -> ('i, 'o) facet
4545-4646- type t = Jv.t
4747-4848- include (Jv.Id : Jv.CONV with type t := t)
4949-5050- let create ?(config = Jv.undefined) () =
5151- let editor_state = Jv.get Jv.global "__CM__state" in
5252- Jv.call editor_state "create" [| config |]
5353-5454- let doc t = Jv.get t "doc" |> Text.of_jv
5555-end
5656-5757-(* Helper for function *)
5858-module Func (I : sig
5959- type t
6060-6161- include Jv.CONV with type t := t
6262-end) =
6363-struct
6464- type t = I.t -> unit
6565-6666- let to_jv f = Jv.repr f
6767-end
6868-6969-module View = struct
7070- type t = Jv.t
7171-7272- include (Jv.Id : Jv.CONV with type t := t)
7373-7474- type opts = Jv.t
7575-7676- let opts ?state ?parent ?root ?dispatch () =
7777- let o = Jv.obj [||] in
7878- Jv.set_if_some o "state" state;
7979- Jv.set_if_some o "root" (Option.map Brr.Document.to_jv root);
8080- Jv.set_if_some o "dispatch" dispatch;
8181- Jv.set_if_some o "parent" (Option.map Brr.El.to_jv parent);
8282- o
8383-8484- let g = Jv.get Jv.global "__CM__view"
8585- let create ?(opts = Jv.undefined) () = Jv.new' g [| opts |]
8686- let state t = Jv.get t "state" |> State.of_jv
8787- let set_state t v = Jv.call t "setState" [| State.to_jv v |] |> ignore
8888-8989- module Update = struct
9090- type t = Jv.t
9191-9292- let state t = State.of_jv @@ Jv.get t "state"
9393-9494- include (Jv.Id : Jv.CONV with type t := t)
9595- end
9696-9797- let dom t = Jv.get t "dom" |> Brr.El.of_jv
9898-9999- let update_listener _ : (Update.t -> unit, Jv.t) State.facet =
100100- let module F = State.FacetMaker (Func (Update)) in
101101- let jv = Jv.get g "updateListener" in
102102- Facet ((module F), F.of_jv jv)
103103-104104- let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
105105-end
-84
vendor/jsoo-code-mirror/src/editor.mli
···11-module State : sig
22- type t
33-44- include Jv.CONV with type t := t
55-66- module Config : sig
77- type t
88-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
1717-1818- module type Facet = sig
1919- type t
2020-2121- include Jv.CONV with type t := t
2222-2323- type input
2424- type output
2525-2626- val of_ : t -> input -> Extension.t
2727- end
2828-2929- module FacetMaker : functor
3030- (I : sig
3131- type t
3232-3333- include Jv.CONV with type t := t
3434- end)
3535- -> Facet with type input = I.t
3636-3737- type ('i, 'o) facet =
3838- | Facet :
3939- (module Facet with type input = 'i and type output = 'o and type t = 'a)
4040- * 'a
4141- -> ('i, 'o) facet
4242-4343- val create : ?config:Config.t -> unit -> t
4444- val doc : t -> Text.t
4545-end
4646-4747-module View : sig
4848- type t
4949- (** Editor view *)
5050-5151- include Jv.CONV with type t := t
5252-5353- type opts
5454- (** Configurable options for the editor view *)
5555-5656- (* TODO: Dispatch function *)
5757- val opts :
5858- ?state:State.t ->
5959- ?parent:Brr.El.t ->
6060- ?root:Brr.El.document ->
6161- ?dispatch:Jv.t ->
6262- unit ->
6363- opts
6464-6565- val create : ?opts:opts -> unit -> t
6666- (** Create a new view *)
6767-6868- val state : t -> State.t
6969- (** Current editor state *)
7070-7171- val set_state : t -> State.t -> unit
7272-7373- module Update : sig
7474- type t
7575-7676- val state : t -> State.t
7777-7878- include Jv.CONV with type t := t
7979- end
8080-8181- val dom : t -> Brr.El.t
8282- val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
8383- val line_wrapping : unit -> Extension.t
8484-end
-3
vendor/jsoo-code-mirror/src/extension.ml
···11-type t = Jv.t
22-33-include (Jv.Id : Jv.CONV with type t := t)
-4
vendor/jsoo-code-mirror/src/extension.mli
···11-type t
22-(** Extensions for the editor *)
33-44-include Jv.CONV with type t := t
···11-open Code_mirror
22-33-let lint = Jv.get Jv.global "__CM__lint"
44-55-module Action = struct
66- type t = Jv.t
77-88- let create ~name f =
99- let f' view from to_ =
1010- let view = Editor.View.of_jv view in
1111- let from = Jv.to_int from in
1212- let to_ = Jv.to_int to_ in
1313- f ~view ~from ~to_
1414- in
1515- let o = Jv.obj [||] in
1616- Jv.Jstr.set o "name" (Jstr.v name);
1717- Jv.set o "apply" (Jv.repr f');
1818- o
1919-2020- include (Jv.Id : Jv.CONV with type t := t)
2121-end
2222-2323-module Diagnostic = struct
2424- type t = Jv.t
2525-2626- let from t = Jv.Int.get t "from"
2727- let to_ t = Jv.Int.get t "to"
2828-2929- type severity = Info | Warning | Error
3030-3131- let severity_of_string = function
3232- | "info" -> Info
3333- | "warning" -> Warning
3434- | "error" -> Error
3535- | _ -> raise (Invalid_argument "Unknown severity level")
3636-3737- let severity_to_string = function
3838- | Info -> "info"
3939- | Warning -> "warning"
4040- | Error -> "error"
4141-4242- let severity t =
4343- Jv.Jstr.get t "severity" |> Jstr.to_string |> severity_of_string
4444-4545- let create ?source ?actions ~from ~to_ ~severity ~message () =
4646- let o = Jv.obj [||] in
4747- Jv.Int.set o "from" from;
4848- Jv.Int.set o "to" to_;
4949- Jv.Jstr.set o "severity" (severity_to_string severity |> Jstr.v);
5050- Jv.Jstr.set o "message" (Jstr.v message);
5151- Jv.Jstr.set_if_some o "source" (Option.map Jstr.v source);
5252- Jv.set_if_some o "actions" (Option.map (Jv.of_array Action.to_jv) actions);
5353- o
5454-5555- let source t = Jv.Jstr.find t "source"
5656- let message t = Jv.Jstr.get t "message"
5757- let actions t = Option.map (Jv.to_array Action.to_jv) (Jv.find t "actions")
5858-5959- include (Jv.Id : Jv.CONV with type t := t)
6060-end
6161-6262-let create ?delay
6363- (source : Code_mirror.Editor.View.t -> Diagnostic.t array Fut.t) =
6464- let o =
6565- match delay with
6666- | None -> Jv.obj [||]
6767- | Some d -> Jv.obj [| ("delay", Jv.of_int d) |]
6868- in
6969- let source' view =
7070- let fut =
7171- Fut.map (Jv.of_array Diagnostic.to_jv) @@ source (Editor.View.of_jv view)
7272- in
7373- Fut.to_promise ~ok:Fun.id (Fut.map Result.ok fut)
7474- in
7575- let ext = Jv.call lint "linter" [| Jv.repr source'; o |] in
7676- Code_mirror.Extension.of_jv ext
-43
vendor/jsoo-code-mirror/src/lint/lint.mli
···11-open Code_mirror
22-33-val lint : Jv.t
44-(** Global lint value *)
55-66-module Action : sig
77- type t
88- (** The type for actions associated with a diagnostic *)
99-1010- val create :
1111- name:string -> (view:Editor.View.t -> from:int -> to_:int -> unit) -> t
1212- (** [create ~name f] makes a new action with a function to call when the user activates the action *)
1313-end
1414-1515-module Diagnostic : sig
1616- type t
1717- type severity = Info | Warning | Error
1818-1919- val severity_of_string : string -> severity
2020- val severity_to_string : severity -> string
2121-2222- val create :
2323- ?source:string ->
2424- ?actions:t array ->
2525- from:int ->
2626- to_:int ->
2727- severity:severity ->
2828- message:string ->
2929- unit ->
3030- t
3131-3232- val severity : t -> severity
3333- val from : t -> int
3434- val to_ : t -> int
3535- val source : t -> Jstr.t option
3636- val actions : t -> Action.t array option
3737- val message : t -> Jstr.t
3838-end
3939-4040-val create :
4141- ?delay:int ->
4242- (Editor.View.t -> Diagnostic.t array Fut.t) ->
4343- Code_mirror.Extension.t
-20
vendor/jsoo-code-mirror/src/panel.ml
···11-open Brr
22-33-type t = Jv.t
44-55-include (Jv.Id : Jv.CONV with type t := t)
66-77-let create ?mount ?update ?top ?pos dom =
88- 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
-12
vendor/jsoo-code-mirror/src/panel.mli
···11-type t
22-(** Editor panels *)
33-44-include Jv.CONV with type t := t
55-66-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
···11-let g = Jv.get Jv.global "__CM__stream_parser"
22-33-module Language = struct
44- type t
55-66- include (Jv.Id : Jv.CONV with type t := t)
77-88- let g = Jv.get g "StreamLanguage"
99-1010- let define (l : t) =
1111- Jv.call g "define" [| to_jv l |] |> Code_mirror.Extension.of_jv
1212-end
-17
vendor/jsoo-code-mirror/src/text.ml
···11-type t = Jv.t
22-33-include (Jv.Id : Jv.CONV with type t := t)
44-55-module Line = struct
66- type t = Jv.t
77-88- let from t = Jv.Int.get t "from"
99- let to_ t = Jv.Int.get t "to"
1010- let number t = Jv.Int.get t "number"
1111- let text t = Jv.Jstr.get t "text"
1212- let length t = Jv.Int.get t "length"
1313-end
1414-1515-let length t = Jv.Int.get t "length"
1616-let line n t = Jv.call t "line" [| Jv.of_int n |]
1717-let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
-29
vendor/jsoo-code-mirror/src/text.mli
···11-type t
22-33-include Jv.CONV with type t := t
44-55-module Line : sig
66- type t
77- (** A text line *)
88-99- val from : t -> int
1010- (** Position of the start of the line *)
1111-1212- val to_ : t -> int
1313- (** Position at the end of the line before the line break *)
1414-1515- val number : t -> int
1616- (** Line's number (1-based) *)
1717-1818- val text : t -> Jstr.t
1919- (** Line's text *)
2020-2121- val length : t -> int
2222- (** The length of the line *)
2323-end
2424-2525-val length : t -> int
2626-(** Length of the text *)
2727-2828-val line : int -> t -> Line.t
2929-val to_jstr_array : t -> Jstr.t array
···11-open Code_mirror
22-33-module Tooltip_view = struct
44- type t = Jv.t
55-66- include (Jv.Id : Jv.CONV with type t := t)
77-88- let dom t = Jv.get t "dom" |> Brr.El.of_jv
99-1010- type offset = { x : int; y : int }
1111- type coords = { left : int; right : int; top : int; bottom : int }
1212-1313- let offset_of_jv o = { x = Jv.Int.get o "x"; y = Jv.Int.get o "y" }
1414-1515- let offset_to_jv { x; y } =
1616- let o = Jv.obj [||] in
1717- Jv.Int.set o "x" x;
1818- Jv.Int.set o "y" y;
1919- o
2020-2121- let _coords_of_jv o =
2222- {
2323- left = Jv.Int.get o "left";
2424- right = Jv.Int.get o "right";
2525- top = Jv.Int.get o "top";
2626- bottom = Jv.Int.get o "bottom";
2727- }
2828-2929- let coords_to_jv { left; right; top; bottom } =
3030- let o = Jv.obj [||] in
3131- Jv.Int.set o "left" left;
3232- Jv.Int.set o "right" right;
3333- Jv.Int.set o "top" top;
3434- Jv.Int.set o "bottom" bottom;
3535- o
3636-3737- let offset t = Jv.get t "offset" |> offset_of_jv
3838-3939- let create ~dom ?offset ?get_coords ?overlap ?mount ?update ?positioned () =
4040- let get_coords =
4141- Option.map
4242- (fun get_coords ->
4343- Jv.repr (fun pos -> get_coords (Jv.to_int pos) |> coords_to_jv))
4444- get_coords
4545- in
4646- let o = Jv.obj [||] in
4747- Jv.set o "dom" (Brr.El.to_jv dom);
4848- Jv.set_if_some o "offset" @@ Option.map offset_to_jv offset;
4949- Jv.set_if_some o "getCoords" get_coords;
5050- Jv.Bool.set_if_some o "overlap" overlap;
5151- Jv.set_if_some o "mount"
5252- @@ Option.map
5353- (fun mount -> Jv.repr (fun view -> mount (Editor.View.of_jv view)))
5454- mount;
5555- Jv.set_if_some o "update"
5656- @@ Option.map
5757- (fun update ->
5858- Jv.repr (fun view_up -> update (Editor.View.Update.of_jv view_up)))
5959- update;
6060- Jv.set_if_some o "positioned" @@ Option.map Jv.repr positioned;
6161- o
6262-end
6363-6464-module Tooltip = struct
6565- type t = Jv.t
6666-6767- include (Jv.Id : Jv.CONV with type t := t)
6868-6969- let pos t = Jv.Int.get t "pos"
7070- let end_ t = Jv.to_option Jv.to_int @@ Jv.get t "end"
7171-7272- let create ~pos ?end_ ~create ?above ?strict_side ?arrow () =
7373- let o = Jv.obj [||] in
7474- Jv.Int.set o "pos" pos;
7575- Jv.Int.set_if_some o "end" end_;
7676- Jv.set o "create"
7777- @@ Jv.repr (fun view ->
7878- create (Editor.View.of_jv view) |> Tooltip_view.to_jv);
7979- Jv.Bool.set_if_some o "above" above;
8080- Jv.Bool.set_if_some o "strictSide" strict_side;
8181- Jv.Bool.set_if_some o "arrow" arrow;
8282- o
8383-end
8484-8585-type hover_config = Jv.t
8686-8787-let hover_config ?hide_on_change ?hover_time () =
8888- let o = Jv.obj [||] in
8989- Jv.Bool.set_if_some o "hide_on_change" hide_on_change;
9090- Jv.Int.set_if_some o "hover_time" hover_time;
9191- o
9292-9393-let hover_tooltip ?config source =
9494- (* let g = Jv.get Jv.global "__CM__hoverTooltip" in *)
9595- let source =
9696- Jv.repr @@ fun view pos side ->
9797- let fut =
9898- source ~view:(Editor.View.of_jv view) ~pos:(Jv.to_int pos)
9999- ~side:(Jv.to_int side)
100100- in
101101- let fut = Fut.map (fun v -> Ok v) fut in
102102- Fut.to_promise fut ~ok:(fun t ->
103103- Option.value ~default:Jv.null (Option.map Tooltip.to_jv t))
104104- in
105105- let args =
106106- if Option.is_none config then [| source |]
107107- else [| source; Option.get config |]
108108- in
109109- Jv.call Jv.global "__CM__hoverTooltip" args |> Extension.of_jv
-113
vendor/jsoo-code-mirror/src/tooltip/tooltip.mli
···11-open Code_mirror
22-33-module Tooltip_view : sig
44- (** Describes the way a tooltip is displayed. *)
55-66- type t
77- (** TooltypeView *)
88-99- include Jv.CONV with type t := t
1010-1111- val dom : t -> Brr.El.t
1212- (** The DOM element to position over the editor. *)
1313-1414- type offset = { x : int; y : int }
1515- type coords = { left : int; right : int; top : int; bottom : int }
1616-1717- val offset : t -> offset
1818-1919- val create :
2020- dom:Brr.El.t ->
2121- ?offset:offset ->
2222- ?get_coords:(int -> coords) ->
2323- ?overlap:bool ->
2424- ?mount:(Editor.View.t -> unit) ->
2525- ?update:(Editor.View.Update.t -> unit) ->
2626- ?positioned:(unit -> unit) ->
2727- unit ->
2828- t
2929- (** Creates a TooltipView:
3030-3131- @param dom The DOM element to position over the editor.
3232- @param offset Adjust the position of the tooltip relative to its anchor
3333- position.
3434- @param get_coords This method can be provided to make the tooltip view
3535- itself responsible for finding its screen position.
3636- @param overlap By default, tooltips are moved when they overlap with other
3737- tooltips. Set this to true to disable that behavior for this tooltip.
3838- @param mount Called after the tooltip is added to the DOM for the first
3939- time.
4040- @param update Update the DOM element for a change in the view's state.
4141- @param positioned Called when the tooltip has been (re)positioned.
4242-4343- {{:https://codemirror.net/6/docs/ref/#tooltip.TooltipView} See the
4444- reference for additional information.} *)
4545-end
4646-4747-(** Creates a Tooltip:
4848-4949- @param pos The document position at which to show the tooltip.
5050- @param end The end of the range annotated by this tooltip, if different from
5151- pos.
5252- @param create A constructor function that creates the tooltip's DOM
5353- representation.
5454- @param above Whether the tooltip should be shown above or below the target
5555- position.
5656- @param strict_side Whether the above option should be honored when there
5757- isn't enough space on that side to show the tooltip inside the viewport.
5858- @param arrow When set to true, show a triangle connecting the tooltip element
5959- to position pos.
6060-6161- {{:https://codemirror.net/6/docs/ref/#tooltip.Tooltip} See the
6262- reference for additional information.} *)
6363-module Tooltip : sig
6464- (** Describes a tooltip. Values of this type, when provided through the
6565- show_tooltip facet, control the individual tooltips on the editor. *)
6666-6767- type t
6868- (** Tooltip *)
6969-7070- include Jv.CONV with type t := t
7171-7272- val pos : t -> int
7373- (** The document position at which to show the tooltip. *)
7474-7575- val end_ : t -> int option
7676- (** The end of the range annotated by this tooltip, if different from pos. *)
7777-7878- val create :
7979- pos:int ->
8080- ?end_:int ->
8181- create:(Editor.View.t -> Tooltip_view.t) ->
8282- ?above:bool ->
8383- ?strict_side:bool ->
8484- ?arrow:bool ->
8585- unit ->
8686- t
8787-end
8888-8989-type hover_config
9090-9191-val hover_config :
9292- ?hide_on_change:bool -> ?hover_time:int -> unit -> hover_config
9393-(** Options for hover tooltips:
9494-9595- @param hover_on_change When enabled (this defaults to false), close the
9696- tooltip whenever the document changes.
9797-@param hover_time Hover time after which the tooltip should appear, in
9898-milliseconds. Defaults to 300ms. *)
9999-100100-val hover_tooltip :
101101- ?config:hover_config ->
102102- (view:Editor.View.t -> pos:int -> side:int -> Tooltip.t option Fut.t) ->
103103- Extension.t
104104-(** Enable a hover tooltip, which shows up when the pointer hovers over ranges
105105- of text. The callback is called when the mouse hovers over the document text.
106106- It should, if there is a tooltip associated with position pos return the
107107- tooltip description (either directly or in a promise). The side argument
108108- indicates on which side of the position the pointer is—it will be -1 if the
109109- pointer is before the position, 1 if after the position.
110110-111111- Note that all hover tooltips are hosted within a single tooltip container
112112- element. This allows multiple tooltips over the same range to be "merged"
113113- together without overlapping. *)