Module Stk.RopeSource

Rope to store text with tags.

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

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

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

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

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

Sourcetype t =
  1. | Leaf of leaf
  2. | Node of node
Sourceand parent =
  1. | Left of node
  2. | Right of node
Sourceand 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

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