package stk

  1. Overview
  2. Docs

Rope to store text with tags.

This module should not be used directly by library user, but rather through the Textbuffer module.

module Tag = Texttag.T
module TagSet = Texttag.TSet
type char = Stdlib.Uchar.t
type range = {
  1. start : int;
  2. size : int;
}

A range is a start position and a size. Both are in Utf8 characters, not in byte.

val pp_range : Stdlib.Format.formatter -> range -> unit
val string_of_range : range -> string
val range : start:int -> size:int -> range
val zero_range : range

zero_range is range ~start:0 size:0. Typically used for accumulators start value.

type t =
  1. | Leaf of leaf
  2. | Node of node
and parent =
  1. | Left of node
  2. | Right of node
and leaf = {
  1. mutable parent : parent option;
    (*

    a leaf with no parent means it is not part of the rope any more

    *)
  2. mutable size : int;
  3. mutable contents : Stdlib.Buffer.t;
  4. mutable tags : (TagSet.t * Tag.t option) array;
    (*

    set of tags, optional lang tag

    *)
}
and node = {
  1. mutable parent : parent option;
  2. mutable size_l : int;
  3. mutable left : t;
  4. mutable size_r : int;
  5. mutable right : t;
}
val no_tag : TagSet.t * 'a option
val zero_tags : (TagSet.t * Tag.t option) array
val parent : t -> parent option
val leaf_offset : leaf -> int option
val rope_size : t -> int
val check : t -> unit
val pp_leaf : Stdlib.Format.formatter -> leaf -> unit
val pp : Stdlib.Format.formatter -> t -> unit
val iter : (Stdlib.Buffer.t -> 'a) -> t -> 'a
val create_leaf : ?parent:parent -> (TagSet.t * Tag.t option) array -> int -> string -> leaf
val set_leaf : leaf -> ?parent:parent option -> (TagSet.t * Tag.t option) array -> int -> string -> unit
val create : unit -> t
val leaf_at : t -> int -> (int * leaf) option
val move_in_rope : target:int -> pos:int -> t -> int * int * leaf
val update_parent_size : parent option -> int -> unit
val update_parent_left_size : node -> int -> unit
val update_parent_right_size : node -> int -> unit
val cut_leaf : leaf -> int -> t
val max_leaf_size : int Stdlib.ref
val insert_string : t -> ?tags:TagSet.t -> string -> int -> int
val cut_from_leaf : at:int -> size:int -> leaf -> t * string
val delete : t -> start:int -> size:int -> string
val of_string : string -> t
val append_string : t -> ?tags:TagSet.t -> string -> unit
val concat : t -> t -> unit
val insert_at_leaf : leaf -> ?tags:TagSet.t -> string -> int -> int
val to_buffer : ?b:Stdlib.Buffer.t -> t -> Stdlib.Buffer.t
val to_string : t -> string
val sub_to_buffer : Stdlib.Buffer.t -> start:int -> size:int -> t -> unit
val sub_to_string : ?b:'a -> start:int -> size:int -> t -> string
val go_down : t -> leaf
val next_leaf : t -> leaf option
val sedlexbuf_refill : ?pos:int -> ?offset:int -> t -> Stdlib.Uchar.t array -> int -> int -> int
val to_sedlexbuf : ?pos:int -> ?offset:int -> t -> Sedlexing.lexbuf
val sub_to_chars : start:int -> size:int -> t -> (Stdlib.Uchar.t * (TagSet.t * Tag.t option)) list
val get : t -> int -> Stdlib.Uchar.t * (TagSet.t * Tag.t option)
val tag_op : t -> (int -> (TagSet.t * Tag.t option) -> TagSet.t * Tag.t option) -> start:int -> size:int -> unit
val add_tag : t -> TagSet.id -> start:int -> size:int -> unit
val remove_tag : t -> TagSet.id -> start:int -> size:int -> unit
val remove_lang_tags : t -> unit
val apply_lang : t -> string -> range list
OCaml

Innovation. Community. Security.