this repo has no description
1(** CodeMirror editor wrapper.
2
3 Wraps a CodeMirror 6 editor view with support for:
4 - Line number offsets (so cells display correct line numbers in a chain)
5 - Inline output messages (displayed as decorations after code)
6 - Merlin extensions (completions, type-on-hover, error highlighting)
7 - Change tracking with invalidation callbacks
8
9 The editor is created inside a shadow DOM element and requires the
10 CodeMirror [basic_setup] extension to be available at creation time. *)
11
12type t
13(** A CodeMirror editor instance with associated state. *)
14
15val make : ?read_only:bool -> Brr.El.t -> t
16(** [make ?read_only parent] creates a new editor inside [parent].
17
18 @param read_only If [true], the editor content cannot be modified.
19 Uses the CodeMirror [readOnly] facet. Default is [false]. *)
20
21val source : t -> string
22(** The current document text. *)
23
24val set_source : t -> string -> unit
25(** Replace the entire document. Also updates the internal doc cache
26 and clears stale messages. *)
27
28(** {1 Messages} *)
29
30val clear : t -> unit
31(** Clear all messages and refresh line numbers and merlin state. *)
32
33val clear_messages : t -> unit
34(** Clear output messages only. *)
35
36val add_message : t -> int -> Brr.El.t list -> unit
37(** [add_message editor loc elements] adds output elements at character
38 offset [loc]. The elements are rendered as block widgets below the
39 line containing offset [loc]. *)
40
41(** {1 Line numbers} *)
42
43val nb_lines : t -> int
44(** Total line count: previous lines offset + lines in the current document. *)
45
46val get_previous_lines : t -> int
47(** The line offset from preceding cells. *)
48
49val set_previous_lines : t -> int -> unit
50(** Set the line offset and refresh the gutter. *)
51
52(** {1 Integration} *)
53
54val on_change : t -> (unit -> unit) -> unit
55(** [on_change editor fn] calls [fn] whenever the document changes.
56 Replaces any previously registered change handler. *)
57
58val configure_merlin : t -> (unit -> Code_mirror.Extension.t list) -> unit
59(** [configure_merlin editor ext_fn] sets the merlin extension provider.
60 [ext_fn] is called to get the current list of merlin extensions.
61 Replaces any previously configured provider. *)