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 = 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 : 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 : 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 : Format.formatter -> leaf -> unit
val pp : Format.formatter -> t -> unit
val iter : (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 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:Buffer.t -> t -> Buffer.t
val to_string : t -> string
val sub_to_buffer : 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 -> 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 -> (Uchar.t * (TagSet.t * Tag.t option)) list
val get : t -> int -> 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.